Skip to content
Sharp

Language Upgrades · interview question

Which statement about the 'sealed' keyword in Java is correct?

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

Correct answer

B. It defines a class or interface that can only be subclassed by a specific set of classes.

Why

The 'sealed' keyword is used to restrict which classes can extend or implement a class or interface, allowing only specific classes to do so.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →