Skip to content
Sharp

Language Upgrades · interview question

What role does the 'permits' clause play in a sealed class declaration?

Multiple choiceMediumchapter-12-curatedpremiumlanguage-upgradespattern-matching
Choose one answer
Answer and explanation

Correct answer

B. It specifies the classes that may extend the sealed class.

Why

The 'permits' clause in a sealed class declaration specifies which specific classes are allowed to extend the sealed class, forming a controlled hierarchy.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →