Skip to content
Sharp

Language Upgrades · interview question

In what situation might a sealed class hierarchy be particularly beneficial in a large legacy application?

Multiple choiceHardchapter-12-curatedpremiumlanguage-upgradesmigration-strategy
Choose one answer
Answer and explanation

Correct answer

B. When you need to prevent external libraries from extending your classes

Why

Sealed classes allow developers to define a fixed set of subclasses, which can be particularly useful in large applications to enforce strict control over the class hierarchy, ensuring that only known implementations are used.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →