There are mainly two types of exceptions: checked and unchecked where error is considered as unchecked exception. The sun Microsystems says there are three types of exceptions:
Let's see an example for better clarity.
import java.io.*; class CheckedDemo { public static void main(String args[]) { PrintWriter pw=new PrintWriter("f.txt"); pw.println("Welcome"); System.out.println(25/0); } }
Output
unreported exception FileNotFoundException; must be caught or declared to be thrown
Here when we are compiling this program, the compiler generated a report which represents that there may be a chance FileNotFoundException arises at run time if the welcome.txt file is not found. So in this way the compiler gave this message to the programmer. This is known as checked exception.
ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException etc.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc