What Is The Difference Between An Error And An Exception?


An Exception indicates conditions that a reasonable application might want to catch.

Checked Exceptions

These are exceptions from which a program can recover & it might be a good idea to recover from such exceptions programmatically.

Examples include:


A try-catch block is used to check for these exceptions.

Unchecked Exceptions

These are those exceptions that might not happen if everything is in order, but they do occur.

Examples include :


Many applications will use try-catch or throws clause for RuntimeExceptions & their subclasses but from the language perspective, it is not required to do so.


An Error indicates serious problems that a reasonable application should not try to catch.

Errors are also unchecked exception & the programmer is not required to do anything with these. In fact, it is a bad idea to use a try-catch clause for Errors.

Recovery from an Error is not possible in most cases and the program should be allowed to terminate.

Examples include :

Although Errors are unchecked exceptions, we shouldn't try to deal with them, but it is ok to deal with RuntimeExceptions (also unchecked exceptions) in code.

Checked exceptions should be handled by the code.