Implementing Permitted Subclasses for Sealed Classes
A class `Transaction` is declared as `sealed`. Which statement correctly implements a permitted subclass?
Quick Answer
The answer is a `public non-sealed class Refund extends Transaction`. This is correct because Java 17’s sealed class feature requires every permitted subclass to be declared with exactly one of three modifiers: `sealed`, `non-sealed`, or `final`. The `non-sealed` modifier explicitly reopens the class hierarchy, allowing `Refund` to be extended further, which is a valid and intentional design choice for a permitted subclass. On the Oracle Certified Professional Java SE 17 Developer 1Z0-829 exam, this concept tests your understanding of how sealed classes enforce a controlled inheritance hierarchy; a common trap is forgetting that a permitted subclass cannot simply be left unmarked—it must carry one of the three keywords. To remember, think of the three “keys” to unlock a sealed hierarchy: `sealed` (keep it sealed), `non-sealed` (open it up), or `final` (lock it down).
⚠ Common exam trap
Watch out — candidates often think only `final` or `sealed` are valid for permitted subclasses, forgetting that `non-sealed` is also a valid modifier that explicitly reopens the hierarchy.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
`public non-sealed class Refund extends Transaction`
A sealed class requires its permitted subclasses to be explicitly declared with `sealed`, `non-sealed`, or `final`. The `non-sealed` modifier allows the subclass to be extended further, which is valid for a permitted subclass of a sealed class.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
`public non-sealed class Refund extends Transaction`
Why this is correct
Correct. The `non-sealed` modifier allows further subclassing, which is a valid implementation of a permitted subclass of a sealed class.
- ✗
`public sealed class Refund extends Transaction permits CashRefund`
Why it's wrong here
Incorrect. Although a subclass can be declared as `sealed`, this option introduces an unnecessary `permits` clause for `CashRefund`, which is not defined and distracts from the core requirement.
- ✗
`public final class Refund extends Transaction`
Why it's wrong here
Incorrect. A `final` subclass is valid for a sealed class, but the question expects the subclass to be extendable, so `non-sealed` is the intended correct modifier.
- ✗
`public class Refund extends Transaction`
Why it's wrong here
Incorrect. A subclass of a sealed class must be declared with `sealed`, `non-sealed`, or `final`. Omitting the modifier causes a compilation error.
Go deeper
Related to this question
About these practice questions
One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on 1Z0-829
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Refer to the exhibit. Given the following code: ```java 1: sealed interface Shape permits Circle { } ... 10: class Circle implements Shape { } ``` What is the result?
medium- A.Compilation fails due to missing permits in Circle
- ✓ B.Compilation fails at line 10
- C.Runtime exception
- D.Compilation succeeds
Why B: In Java 17, when a sealed interface (like `Shape`) declares a `permits` clause listing permitted subclasses (e.g., `Circle`), each permitted subclass must explicitly declare itself as `sealed`, `non-sealed`, or `final`. If the `Circle` class is defined as `class Circle implements Shape` without any of these modifiers, compilation fails at line 10 where that class is defined. The error is that the class is not allowed to extend/implement the sealed interface unless it has the required modifier.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.