Throwable acts as a root for exception hierarchy.
The throwable class contains the following two child classes.
Exception: Most of the cases exceptions are caused by our program and these are recoverable.
Error: Most of the cases errors are not caused by our program these are due to lack of system
resources and these are non-recoverable.
Checked Vs Unchecked Exceptions:
• The exceptions which are checked by the compiler for smooth execution of the program at runtime are called checked exceptions.
1) HallTicketMissingException
2) PenNotWorkingException
3) FileNotFoundException
• The exceptions which are not checked by the compiler are called unchecked exceptions.
1) BombBlaustException
2) ArithmeticException
3) NullPointerException
Note: RuntimeException and its child classes, Error, and its child classes are unchecked and all the remaining are considered as checked exceptions.
Note: Whether exception is checked or unchecked compulsory it should occur at runtime only there is no chance of occurring any exception at compile time.
Partially checked Vs fully checked:
• A checked exception is said to be fully checked if and only if all its child classes are also checked.
Example:
1) IOException
2) InterruptedException
• A checked exception is said to be partially checked if and only if some of its child classes are unchecked.
Example: Exception
• The only partially checked exceptions available in java are:
1. Throwable.
2. Exception.
Which of the following are checked?
1. RuntimeException-----unchecked
2. Error-----unchecked
3. IOException-----fully checked
4. Exception-----partially checked
5. InterruptedException-----fully checked
6. Throwable------partially checked
Diagram:
Comments
Post a Comment