Skip to content
Sharp

Language Upgrades · interview question

In Java, which statement is true about the use of the 'sealed' keyword?

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

Correct answer

A. It restricts which classes can extend or implement a class or interface.

Why

The 'sealed' keyword in Java is used to restrict which classes can extend or implement a given class or interface, providing better control over the class hierarchy and enabling exhaustiveness checks in switch statements.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →