Skip to content
Sharp

Exceptions · interview question

In an e-commerce checkout system, which exception type should you use for handling invalid payment details?

Multiple choiceMediumchapter-6-curatedpremiumexceptionsreliable-java-error-design
Choose one answer
Answer and explanation

Correct answer

A. IllegalArgumentException

Why

IllegalArgumentException is appropriate for scenarios where a method has been passed an illegal or inappropriate argument, such as invalid payment details.

Test yourself on Exceptions

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

Start free test
All Exceptions questions →