Skip to content
Sharp

Exceptions · interview question

Consider the following code snippet. What is the primary issue with the exception handling?

Multiple choiceHardchapter-6-curatedpremiumexceptionscause-chaining-and-error-context
java
try { // some code } catch (IOException e) { throw new OrderProcessingException("Order failed"); }
Choose one answer
Answer and explanation

Correct answer

D. The original exception cause is lost.

Why

The code loses the original exception cause by not passing it to the new exception, which makes it difficult to trace the error's origin.

Test yourself on Exceptions

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

Start free test
All Exceptions questions →