Checked Vs Unchecked Exceptions in Java

In java there are two type of exceptions are generated. i.e.

Checked Exception

  • Occur at compile time.
  • Also known as Compile Time Exception.
  • Checked by the compiler.
  • Handled during the time of compilation.
  • JVM needs the exception to be catch or handle.
  • Shows recoverable conditions.

Examples of Checked Exceptions

  1. File Not Found Exception
  2. No Such Field Exception
  3. Interrupted Exception
  4. No Such Method Exception
  5. Class Not Found Exception

Unchecked Exception

  • Occur at runtime.
  • Also known as Run Time Exception.
  • Unchecked by the compiler.
  • Exceptions cannot be a catch or handle during time of compilation.
  • These exceptions are not a part of the Exception class.
  • JVM does not needs the exception to be catch or handle.
  • Shows programming errors.

Examples of Unchecked Exceptions

  1. No Such Element Exception
  2. Undeclared Throwable Exception
  3. Empty Stack Exception
  4. Arithmetic Exception
  5. Null Pointer Exception
  6. Array Index Out of Bounds Exception
  7. Security Exception
Checked Vs Unchecked
Checked Vs Unchecked