Skip to content
Sharp

Exceptions · interview question

Why validate an empty cart or invalid quantity before contacting inventory or payment systems?

Multiple choiceMediumchapter-6-curatedpremiumexceptionsfail-fast-validation
Choose one answer
Answer and explanation

Correct answer

B. To reject cheap invalid state before expensive or irreversible work begins

Why

Fail-fast validation keeps invalid state from spreading and avoids wasting network calls or partial external actions on requests that should have been rejected immediately.

Test yourself on Exceptions

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

Start free test
All Exceptions questions →