Checked Exceptions are those which are checked by compiler during compile time only. These need to handled either by try catch block or by throwing the exception. Examples of same are ::
ClassNotFoundException, InterruptedException, InstantiationException, IOException,
SQLException, IllegalAccessException, FileNotFoundException,CloneNotSupportedException.
All exceptions except RunTimeException and Error are checked Exception.
In case of checked exception Compiler reports unhandled exception FileNotFoundException or must be caught or declared to be thrown during compiletime.
Unchecked Exceptions are those which are not checked by compiler and occurs due to error in programming logic. Examples ClassCastException extends RunTimeException, ClassGenException extends RunTimeException ,ArithmeticException,IndexOutOfBoundsException extends RunTimeException, ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException, ConcurrentModification Exception, NumberFormatException.
All exceptions under (RuntimeException and Error ) are unchecked Exception.
Exception hierarchy
Object
|
Throwable
|
Exceptions Error
| |
I/O. Runtime CloneNotSupported. Linkage Assertion VirtualMachineError
No comments:
Post a Comment