What does the permits clause of a sealed Java class specify?
Correct answer A. The classes allowed to directly extend it
Explanation
A sealed class restricts inheritance, and its permits clause names the classes allowed to be its direct subclasses. Each one must then be declared final, sealed or non-sealed. This closed hierarchy lets the compiler check that a pattern switch covers every case. Sealed classes became a standard feature in Java 17.
Answer checked How we write and check questions
Discussion