Skip to content
Sharp

Language Upgrades · interview question

Which of the following statements about sealed classes is true?

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

Correct answer

D. A sealed class must be final if it has no subclasses.

Why

If a sealed class does not have any subclasses, it must be declared as final to indicate that it cannot be extended. This is part of maintaining a controlled class hierarchy.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →