Q21: How is the Java Exception Class Hierarchy structured (Checked vs Unchecked)?

Throwable is the root class, branching into Error and Exception:

  • Checked Exceptions: Subclasses of Exception (excluding RuntimeException). The compiler forces developers to catch or declare them (IOException, SQLException). Represents recoverable conditions.
  • Unchecked Exceptions: Subclasses of RuntimeException (NullPointerException, IllegalArgumentException). Represents programming bugs.
  • Error: Serious system failures (OutOfMemoryError, StackOverflowError). Applications should not attempt recovery.
Throwable Class Hierarchy Structure
Key Takeaways
  • Checked = Forced by compiler (Exception subclasses). Unchecked = Runtime errors (RuntimeException subclasses).
Knowledge Check

Which of the following exceptions is a CHECKED exception enforced by the Java compiler?