Exception hierarchy

We know that, In java, Exception can be either checked or unchecked and same has been shown in the below exception hierarchy

Parent class of all exceptions in java is “Throwable” class.

Any instance of Throwable class can be caught using catch block except Error.

We can’t handle errors in Java through program.

exception_Hierarchy

Exception hierarchy mainly consists of Exception and Error

Where Error is something which we can’t handle programmatically but we can handle exceptions through program.

Any subclass of Exception can be handled programmatically in Java.

Throwable represent the super class of all exceptions and also Runtime Errors in Java.

Exception and its sub-classes represent unusual conditions in a program which is expected to occur but can recover from.

It has all the behaviours of checked exception.

Example : FileNotFoundException,SQLException

RuntimeException is a subclass of Exception

RuntimeException and its sub-classes represent unusual conditions in a program which is generally not expected to occur but can recover from.

It has all the behaviours of unchecked exception.

Example : NullPointerException,ArithmeticException

Error sub-classes represent “serious” errors that a program can’t catch and recover from.

Example : expected class file being missing, or an OutOfMemoryError.

Exception class acts as checked exception and its subclass RuntimeException class acts as Unchecked exception.

Remember :
Checked exceptions are forced by compiler to handle whereas unchecked exceptions are not forced to handle but Its good to handle.

About the Author

Karibasappa G C (KB)
Founder of javainsimpleway.com
I love Java and open source technologies and very much passionate about software development.
I like to share my knowledge with others especially on technology 🙂
I have given all the examples as simple as possible to understand for the beginners.
All the code posted on my blog is developed,compiled and tested in my development environment.
If you find any mistakes or bugs, Please drop an email to kb.knowledge.sharing@gmail.com

Connect with me on Facebook for more updates

Share this article on