Skip to content
Sharp

Language Upgrades · interview question

What happens if you try to extend a sealed class without listing the subclass in the 'permits' clause?

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

Correct answer

C. Compile-time error

Why

If a class attempts to extend a sealed class without being listed in the 'permits' clause, it results in a compile-time error. This ensures the integrity of the class hierarchy.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →