Skip to content
Sharp

Exceptions · interview question

Why does rejecting invalid input early in a method matter in practice?

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

Correct answer

C. To prevent invalid state propagation

Why

Early rejection of invalid input prevents the program from entering an invalid state, which can lead to unpredictable behavior and bugs. It also makes the code more robust and easier to maintain.

Test yourself on Exceptions

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

Start free test
All Exceptions questions →