Skip to content
Sharp

Language Upgrades · interview question

Why is a sealed hierarchy a good fit for PaymentResult with only Success, Failure, and Pending states?

Multiple choiceMediumchapter-12-curatedpremiumlanguage-upgradessealed-classes
Choose one answer
Answer and explanation

Correct answer

A. Because the business owns a closed set of valid outcomes and the compiler can enforce exhaustive handling

Why

Sealed hierarchies work best when the valid variants are truly finite and controlled by the business. That lets the compiler check exhaustiveness and helps prevent accidental unsupported states.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →