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.
- 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.
- Sub classes of Exception class comes under “Checked Exceptions”.
- Checked exceptions belongs to corresponding package.
- IOException (java.io)
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.