Exception Hierarchy — Throwable, Error, Exception, RuntimeException
Fast recall
Quick revision
Core answer
Throwable → Error (JVM failures — never catch) + Exception → RuntimeException (unchecked — programmer bugs, no declaration needed) + checked (must declare or catch — caller can recover). NullPointerException, IllegalArgumentException = unchecked. IOException, SQLException = checked. Multi-catch since Java 7: catch (IOException | SQLException e). Never catch bare Exception or Throwable silently.Whether the candidate understands the hierarchy — Throwable → Error/Exception, Exception → checked/unchecked (RuntimeException) — and knows the practical implications of checked vs unchecked exceptions for API design
Catching Exception or Throwable as a blanket catch — swallowing OutOfMemoryError or other Errors that should crash the process. Confusing 'checked' with 'important' — RuntimeExceptions aren't less serious, they just don't require explicit handling
Explain the design philosophy — checked exceptions force callers to handle recoverable failures (IOException), while unchecked exceptions signal programming errors (NullPointerException). Mention that modern frameworks like Spring wrap checked exceptions in unchecked ones because mandatory catch blocks often lead to empty catch blocks
Interview-ready guide
Interview answer
Java's exception hierarchy starts at Throwable, splitting into Error and Exception. Position in that tree determines whether the compiler forces handling.
Error — never catch
OutOfMemoryError,StackOverflowError,NoClassDefFoundError— JVM-level failures- Catching them lets the application continue in a corrupted state; let the process crash and restart
Checked exceptions — caller must handle
- Direct subclasses of
Exception(notRuntimeException):IOException,SQLException,ParseException - Declared in
throws, compiler enforces; signals a recoverable external condition the caller might retry or fall back from
Unchecked (RuntimeException) — fix the code
NullPointerException,IllegalArgumentException,ClassCastException— programming errors- No declaration required; the caller can't meaningfully recover from a bug
The real debate: are checked exceptions worth it?
- The intent is good — force callers to think about failure modes
- In practice, developers often write empty catch blocks, which is worse than no handling
- Spring wraps
SQLExceptioninDataAccessException(unchecked) because most callers have no useful recovery strategy - Use checked exceptions only when the caller genuinely has multiple valid responses to the failure
Gotcha — checked exception anti-pattern:
- Use checked exceptions only when the caller genuinely has multiple valid responses to the failure; otherwise they just add boilerplate
I recommend catching specific exceptions at layer boundaries and never using empty catch blocks.
Exception Hierarchy — Throwable, Error, Exception, RuntimeException
Direct Answer
Throwable → Error (JVM failures — never catch) + Exception → RuntimeException (unchecked — programmer bugs, no declaration needed) + checked (must declare or catch — caller can recover). NullPointerException, IllegalArgumentException = unchecked. IOException, SQLException = checked. Multi-catch since Java 7: catch (IOException | SQLException e). Never catch bare Exception or Throwable silently.
Common Mistakes & Pitfalls
Catching Exception or Throwable as a blanket catch — swallowing OutOfMemoryError or other Errors that should crash the process. Confusing 'checked' with 'important' — RuntimeExceptions aren't less serious, they just don't require explicit handling
Check your understanding
Answer these without looking back at the article.
- What is the difference between checked and unchecked exceptions — when should you use each?
- Why should you never catch Error in a normal Java application?
- What is exception chaining and why should you always preserve the original cause when wrapping?
- What is wrong with catch(Exception e) {} — what are the consequences of swallowing exceptions?
- When is it appropriate to catch a checked exception and rethrow it as an unchecked one?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.