James Gosling: idealism, the Internet and Java, Pt I

Monday 11 January 2021

Java API support for Exception Handling

First of all, please read below blog post to understand basics of Exception Handling in java.

Exception handling and java keywords


To continue from there, Basically Java default API has hierarchy of  java classes to support different uses cases of exceptions. 

The parent class of all Exceptions and Errors is Throwable. Please check below pictorial representation of  API Hierarchy 

Exception:

The class Exception and any subclasses that are also not subclasses of RuntimeException are checked exceptions.

And all subclasses of RuntimeException and RuntimeException class itself are Unchecked exception. Rest all are Checked exceptions

Examples of Unchecked Exceptions: 

         ArrayIndexOutOfBoundException

         NullPointerException

Error:

An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions.

Examples: The ThreadDeath error


1 comment:

Popular posts

Demonstration of Java NullPointerException

NullPointerException causes and reasons Since Java is object oriented programming language, every thing is considered to be an object. and t...