Checked vs Unchecked Exceptions
Fast recall
Quick revision
Core answer
Exception that is not a subclass of RuntimeException; Java requires a caller to catch it or declare it with throws. An unchecked exception is a RuntimeException subclass and has no catch-or-declare requirement. Error is also unchecked but represents a separate throwable branch. Checked versus unchecked does not by itself decide whether a condition is recoverable.Interview-ready guide
Interview answer
A checked exception is an Exception subtype other than RuntimeException, and Java's compiler requires it to be caught or declared. IOException is a common example. An unchecked exception is a RuntimeException subtype, such as IllegalArgumentException, so the compiler does not impose catch-or-declare. Error is also unchecked but belongs to a different branch of Throwable. The distinction is a language rule, not a promise that checked conditions are recoverable or unchecked ones are always programmer bugs. I choose handling based on what the current layer can meaningfully do, while preserving the original cause when translating exceptions.
Checked vs Unchecked Exceptions
Direct Answer
A checked exception is a subclass of Exception that is not a subclass of RuntimeException; Java requires a caller to catch it or declare it with throws. An unchecked exception is a RuntimeException subclass and has no catch-or-declare requirement. Error is also unchecked but represents a separate throwable branch. Checked versus unchecked does not by itself decide whether a condition is recoverable.
Common Mistakes & Pitfalls
- Catching Exception directly: Writing catch (Exception e) catches everything including unchecked exceptions you shouldn't handle generically. Catch specific checked exceptions you expect.
- Declaring throws Exception: Method signatures with throws Exception are too broad. Declare the specific checked exceptions callers need to know about.
- Making custom exceptions checked by default: Freshers extend Exception for custom errors without thinking. Usually business logic exceptions should be unchecked (extend RuntimeException) so they don't force boilerplate throughout the code.
Check your understanding
Answer these without looking back at the article.
- When would you convert a checked exception to an unchecked exception?
- What happens if you catch Exception vs RuntimeException?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.