Skip to content
Sharp

Language Upgrades · interview question

In Java, what is one advantage of using sealed interfaces?

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

Correct answer

D. They ensure that only specified classes can implement the interface.

Why

Sealed interfaces restrict which classes can implement them, similar to sealed classes. This ensures that only a predefined set of classes can provide implementations, helping maintain architectural integrity and preventing unauthorized implementations.

Test yourself on Language Upgrades

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

Start free test
All Language Upgrades questions →