Start Coding Now

Exception Handling in Java - Overview

Introduction to exceptions in Java. Checked vs Unchecked exceptions and the hierarchy explained.

What is an Exception?

An exception is an event triggering a problem during the execution of a program (runtime).

Exception Hierarchy:

  • Throwable is the parent of all exceptons.
  • Error: Serious problems (OutOfMemoryError).
  • Exception: Conditions that can be caught (IOException, SQLException).

Checked vs Unchecked

  • Checked Exceptions: Checked at compile-time (e.g. IOException). Must be handled.
  • Unchecked Exceptions: Runtime Exceptions (e.g. NullPointerException). Not checked at compile-time.
  • Frequently Asked Questions