Give an example of when you would deliberately use a checked exception instead of an unchecked one.

A checked exception is the right choice when you want the compiler to force callers to acknowledge and handle a recoverable, expected failure condition, rather than letting it fail silently until it surfaces unexpectedly at runtime.

Key Points

Example

A method that reads and parses a configuration file might declare throws IOException, forcing every caller to explicitly decide whether to propagate the failure, retry with a default file, or surface an error to the user, rather than letting a missing file crash the application unexpectedly.

Interview Tip

A concise interview answer is

I'd use a checked exception when a failure is expected and recoverable, like a file not being found or a database call failing, since it forces the caller to explicitly handle it. I'd reserve unchecked exceptions for programming errors like invalid arguments or null references, where the failure indicates a bug rather than something the caller should be expected to recover from.

Last updated: 11 November 2026

Previous question: What happens when an exception is thrown in a static initialization block?

Next question: When have you used a finally block? Describe a scenario.

More Exception Handling interview questions

All Exception Handling questions