Skip to content
Sharp

Language Upgrades · interview question

What must be true for a class to extend a sealed class and be marked as 'non-sealed'?

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

Correct answer

B. It must be listed in the permits clause of the sealed class.

Why

For a class to extend a sealed class and be marked as 'non-sealed', it must first be listed in the sealed class's 'permits' clause. This ensures that the sealed class hierarchy is adhered to, allowing controlled extensions.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →