Checked vs Unchecked Exceptions in Java
Fast recall
Quick revision
Core answer
IOException) force catch-or-declare — use when callers have a real recovery path. Unchecked (RuntimeException) signal bugs — fix code, don't blanket-catch. Frameworks wrap checked DB errors into unchecked DataAccessException.Whether you understand the compiler-enforced contract, can articulate when each type is appropriate, and know how modern Java code trends toward unchecked exceptions
Catching Exception or Throwable as a blanket handler, swallowing exceptions without logging, or using checked exceptions for every failure regardless of whether the caller can recover
Mention that many modern frameworks (Spring, JPA) and languages (Kotlin, Scala) favor unchecked exceptions to reduce boilerplate. Discuss the 'exception translation' pattern and why you should never swallow exceptions silently.
Interview-ready guide
Interview answer
The distinction is about recoverability — checked exceptions represent conditions the caller can reasonably handle; unchecked exceptions represent programming bugs.
Checked exceptions:
- Subclasses of
ExceptionminusRuntimeException— compiler forces catch-or-declare IOException,SQLException,ClassNotFoundException— represent recoverable failures: file not found, network timeout, SQL failure
Unchecked exceptions:
- Subclasses of
RuntimeException— not compiler-enforced NullPointerException,IllegalArgumentException,IndexOutOfBoundsException— represent programming bugs- Catching them hides the real problem instead of fixing the code
Modern trend:
- Spring wraps
SQLExceptioninto uncheckedDataAccessException— reduces noise at every DAO layer - Kotlin and Scala dropped checked exceptions entirely
- Anti-pattern: catching
ExceptionorThrowableas a blanket handler — swallows bugs
I recommend catching specific exceptions at layer boundaries and translating them into domain-specific types — never use catch (Exception e) as a general handler.
Checked vs Unchecked Exceptions in Java
Direct Answer
Checked exceptions (IOException) force catch-or-declare — use when callers have a real recovery path. Unchecked (RuntimeException) signal bugs — fix code, don't blanket-catch. Frameworks wrap checked DB errors into unchecked DataAccessException.
Common Mistakes & Pitfalls
Catching Exception or Throwable as a blanket handler, swallowing exceptions without logging, or using checked exceptions for every failure regardless of whether the caller can recover
Check your understanding
Answer these without looking back at the article.
- What is the exception translation pattern?
- When is it appropriate to catch Exception or Throwable?
- How should you handle exceptions in a Spring @Service layer?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.