Skip to content
Sharp

Exceptions · interview question

In designing a custom exception, which practice is recommended to provide meaningful diagnostics?

Multiple choiceHardchapter-6-curatedpremiumexceptionscustom-exceptions
Choose one answer
Answer and explanation

Correct answer

B. Use an error code and detailed message

Why

Including both an error code and a detailed message in a custom exception helps developers identify the specific issue and its context quickly. This is an effective way to provide meaningful diagnostics.

Test yourself on Exceptions

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

Start free test
All Exceptions questions →