Difference between checked and unchecked exceptions
1) All the subclasses of RuntimeException are called unchecked exception.
All subclasses of Throwable class except RuntimeException are called as checked exceptions
2) Unchecked exceptions need not be handled at compile time. Checked Exceptions need to be handled at compile time.
Unchecked exceptions arise mostly due to coding mistakes in our program.
4)unchecked-ArrayIndexOutOfBoundsException, ClassCastException, IndexOutOfBoundException checked-SqlException, FileNotFoundException,ClassNotFoundException
Difference between Checked Exceptions and Unchecked Exceptions:
1.Checked Exception is an Exception that occurs at the compile time these are also called as compile time Exceptions.while an unchecked exception is an exception that occurs at the time of execution also called a runtime exceptions.
2.Checked Exceptions:These exceptions cannot simply be ignored at the time of compilation,the programmer should take care of these exceptions.While the unchecked Exceptions are ignored at the runtime as it includes programming bugs,logic errors.
3.The compiler checks the checked Exception,while it doesn't check the unchecked exception.
4.Checked Exception:Except "runtime Exception" class all the child classes of the class "Exception",and the "error" class and its child classes are checked exception.In unchecked exception "runtime exception" class and its child classes,are "unchecked exceptions".
5.If we don't handle the checked exception then the compiler objects,whereas in unchecked exception even it we do not handle the compiler doesn't object.
6.The program doesn't compile if there is an checked exception in the program code.Whereas in unchecked exception the program compiles successfully even if there is an unhandled exception in the program code.
7.checked and unchecked exceptions both can be handled using try,catch and finally and they can also be created manually.
8.In checked exceptions the java virtual machine requires the exception to be caught or handled,while in unchecked exceptions the java virtual machine does not require the exception to be caught or handled.