Skip to content
Sharp

Language Upgrades · interview question

How do sealed classes enhance domain modeling rules?

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

Correct answer

B. By restricting class hierarchies to enforce specific rules.

Why

Sealed classes restrict which classes can extend them, allowing developers to enforce domain modeling rules at the language level, preventing unauthorized extensions and ensuring that only valid types are used.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →