Skip to content
Sharp

Exceptions · interview question

Which of the following is a valid reason to throw a custom exception during the checkout process of an e-commerce application?

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

Correct answer

C. To signal an invalid coupon code

Why

A custom exception for an invalid coupon code provides clear context about a specific business rule violation during the checkout process, making it easier to handle and debug.

Test yourself on Exceptions

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

Start free test
All Exceptions questions →