Skip to main content

Exception hierarchy


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

Popular posts from this blog

Core Java

Content 1 - Language fundamental   Identifier Reserved words Data types Literals Arrays Types of variables Var arg method Main method Java coding standards 2 -  Declaration and Access Modifiers Java source file structure Class modifiers Member modifiers Interfaces 3 - Exception Handling Introduction Runtime stack mechanism Default exception handling in java Exception hierarchy Customized exception handling by try-catch  Control flow in try-catch Methods to print exception information Try with multiple catch blocks Finally Difference between final, finally, finalize Control flow in try-catch-finally Control flow in nested try-catch-finally Various possible combinations of try-catch-finally throw keyword throws keyword Exception handling keywords summary Various possible compile-time errors in exception handling Customized exceptions Top-10 exceptions  4 - String Concept of String Immutable String String Comparison String Conca