Exceptions · interview question
In a payment processing API, how should exceptions be propagated?
Multiple choiceHardchapter-6-curatedpremiumexceptionschecked-vs-unchecked-exceptions
Answer and explanation
Correct answer
D. Use checked exceptions for recoverable errors, log and wrap others
Why
In payment processing, using checked exceptions for recoverable errors allows the caller to handle these situations appropriately. Logging and wrapping other exceptions ensures that unexpected issues are recorded and can be addressed without crashing the application.
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?