Exception Hierarchy in Java

This “Exception Hierarchy in Java” page is providing information about Exception classes and Error class in java and why we cannot handle Errors in java.

core-Java-online-Training-4

Exception Hierarchy:

  • java.lang.Throwable is the super class of all the Exceptions.
  • It has 2 direct sub classes Exception & Error
  • Errors can’t be handled in java application.

 

  • Sub classes of RuntimeException class referred as “Unchecked Exceptions”.
  • Un checked exceptions belongs to “java.lang” package.
    1. ArithmeticException
    2. NumberFormatException
    3. ……

 

  • Sub classes of Exception class comes under “Checked Exceptions”.
  • Checked exceptions belongs to corresponding package.
    1. IOException (java.io)
    2. SQLException(java.sql)
    3. ……

Exception Hierarchy in Java

 

Why Errors cannot be handled?

  • Exception is a runtime error. Exception occurs only while application is running.
  • In case of Error, even we cannot start the application execution. Hence these are not comes under exceptions.

core-Java-online-Training-4

Share this