Exceptions · interview question
When is an unchecked exception often the clearer choice?
Multiple choiceMediumchapter-6-curatedpremiumexceptionschecked-vs-unchecked-exceptions
Answer and explanation
Correct answer
D. When the problem is invalid input, misuse, or a broken assumption
Why
Unchecked exceptions are often better for invalid calls, broken invariants, and programmer mistakes. They usually signal that the current usage is wrong rather than a normal recoverable condition the caller should negotiate.
Test yourself on Exceptions
A free test with instant, explained results. No account needed.
More Exceptions questions
- When designing a Java API, how should exceptions be documented?
- Why can catching the Exception class in Java become a real problem?
- How can fail-fast validation impact the design of a Java class intended for secure financial transactions?
- Why can overusing checked exceptions in a library become a problem in production code?
- In which scenario does exception wrapping make code more reliable?
- What role does the 'finally' block serve in Java exception handling?