Java Sealed Interfaces Compilation Rules
Short answer
D Using 'non-sealed' allows the interface to be implemented by any class, breaking the sealed constraint.
Question

Key Takeaways
The core trap is forgetting that any class or interface extending a sealed type must explicitly declare its own sealing status using 'sealed', 'non-sealed', or 'final'.
This question tests the strict syntax requirements for Java sealed interfaces, specifically the mandatory modifiers (sealed, non-sealed, or final). It establishes that a sealed interface cannot be extended by an unmodified interface.
Common mistake: Learners often select option C ('sealed interface') because they assume all extensions of a sealed interface must also be sealed. However, this restricts inheritance to only permitted subclasses, whereas the goal is often to allow broader implementation.
Expert Analysis
Why the Answer Is Correct
Option D compiles because it uses the 'non-sealed' modifier, which allows any other class or interface in the module to implement or extend the 'Story' interface without restriction. This is a valid way to break the sealed hierarchy and permit open inheritance.
Why the Other Options Are Wrong
Option A fails because it lacks a sealing modifier; extending a sealed type requires an explicit modifier. Option B is incorrect for the same reason as A, despite being public. Option C is syntactically correct but likely not the intended answer if the context implies opening the hierarchy, though strictly speaking, it does compile if 'Art' is also defined correctly. However, based on the options provided in the image context (which usually pairs Story and Art), Option E (often cited as missing modifiers in comments) is invalid. The key distinction is that 'non-sealed' opens the API.
Community Comment Notes
Community consensus strongly supports D. Users like 'supersquax' and 'Tojose' note that option E (in some versions) misses necessary modifiers. 'minhdev' clarifies that 'non-sealed' is required to allow external classes to implement the interface, while 'Uteman' confirms that 'non-sealed' opens up inheritance for any class.
Exam Strategy
When dealing with sealed types, always check if the subclass/interface needs to preserve the seal ('sealed'), break it completely ('non-sealed'), or close it ('final'). If the question asks for a definition that allows any class to implement, choose 'non-sealed'.
Frequently Asked Questions
Why can't I use 'sealed' for the implementing interface?
Is 'public' required for a sealed interface?
Community Votes
100% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 9 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 9
-
supersquax 👍 4Right answer is D. E is missing "sealed", "non-sealed" or "final" modifier.
-
Tojose 👍 3The right option is D. non-sealed interface Story extends SInt {} non-sealed interface Art extends SInt {}, because the class in option E require an modifier
-
minhdev 👍 2D is correct, Sealed interface allows sealed, non-sealed interface extends it.
-
filledapril 👍 1if option E is like: E. non-sealed interface Story extends SInt {} non-sealed class Art implements SInt {} , in this case should select the E
-
Uteman 👍 1D is the correct answer non-sealed opens up for any class to implement
Show 4 more comments
-
meltedolive 👍 6Right option is D.
-
Samps 👍 4 Answered DRight answer is D
-
Tangaizw 👍 1How is C wrong?
-
TrinhLK 👍 1D is correct
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.