Skip to content
Sharp

Exceptions · interview question

Why do teams use checked exceptions for API design in production code?

Multiple choiceMediumchapter-6-curatedpremiumexceptionschecked-vs-unchecked-exceptions
Choose one answer
Answer and explanation

Correct answer

B. They enforce error handling at compile time.

Why

Checked exceptions force the caller to handle or declare them, making error handling explicit and ensuring that anticipated problems are dealt with. This can lead to more robust and predictable API usage.

Test yourself on Exceptions

A free test with instant, explained results. No account needed.

Start free test
All Exceptions questions →