Checked vs Unchecked Exceptions in Java
Fast recall
Quick revision
Core answer
Exception subtype other than RuntimeException; Java requires callers to catch it or declare it. RuntimeException and Error subtypes are unchecked. Checked status is a compile-time API rule, not proof that a failure is recoverable, and unchecked exceptions are not limited to programming bugs.Whether you can define the compiler-enforced distinction and place exceptions correctly under RuntimeException or not
Equating checked with recoverable and unchecked with programming bug instead of describing the catch-or-declare rule
Use the exact hierarchy boundary and explain that recoverability belongs to the caller's context
Interview-ready guide
Interview answer
Checked and unchecked describe Java's compile-time handling rule. A checked exception is an Exception subclass that is not a RuntimeException, so code must catch it or declare it when it can escape. RuntimeException subclasses and Error subclasses are unchecked.
For example, Files.readString(path) can throw the checked IOException, so a method either handles that failure or declares throws IOException. Calling Integer.parseInt("abc") can throw the unchecked NumberFormatException; Java does not force a catch or declaration. That does not mean every checked failure is recoverable or every unchecked failure is a programmer bug. Recovery depends on the caller and the application boundary. The category mainly tells callers what the type system requires and forms part of the API contract.
Checked vs Unchecked Exceptions in Java
Direct Answer
A checked exception is an Exception subtype other than RuntimeException; Java requires callers to catch it or declare it. RuntimeException and Error subtypes are unchecked. Checked status is a compile-time API rule, not proof that a failure is recoverable, and unchecked exceptions are not limited to programming bugs.
Common Mistakes & Pitfalls
- Treating the difference as timing — every exception is thrown at runtime;
checkedonly means the compiler checks it at compile time. - Assuming unchecked is less serious — a
NullPointerExceptioncan take down an app just as hard as any checked failure. - Forgetting
Erroris unchecked too —OutOfMemoryErrorand friends sit outside the checked rule alongsideRuntimeException. - Wrapping every call in
try/catchto quiet the compiler — only checked exceptions need handling; blanket-catchingRuntimeExceptionhides real bugs.
Check your understanding
Answer these without looking back at the article.
- Why do modern frameworks like Spring prefer unchecked exceptions?
- Can you convert a checked exception to unchecked?
- What happens if you don't handle a checked exception?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.