Skip to content
Sharp

Exceptions · interview question

How should a method handle exceptions internally if it decides not to propagate them?

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

Correct answer

B. Log the exception and return a default value

Why

When a method handles an exception internally, it should log the exception to maintain a traceable record, and then return a sensible default value if appropriate. This ensures the application continues to function while preserving diagnostic information.

Test yourself on Exceptions

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

Start free test
All Exceptions questions →