Difference Between Error and Exception in Java

In this post, we will understand the difference between error and exception.


  • It is classified as an unchecked type.

  • It belongs to the class ‘java.lang.error’.

  • It can’t be recovered from.

  • It can't occur at compile time.

  • Examples of errors include −

    • ‘OutOfMemoryError’

    • ‘IOError’


  • It can be classified into unchecked and checked exceptions.

  • It belongs to the class ‘java.lang.Exception’.

  • It can be recovered from.

  • It can occur at runtime as well as compile time.

  • Examples of exceptions include −

    • NullPointerException

    • SqlException