1Z0-829 Utilizing Java Object-Oriented Approach Practice Question
Which TWO statements are true about the sealed class feature in Java 17?
⚠ Common exam trap
Test-takers frequently confuse the requirements for subclasses of a sealed class, mistakenly thinking they must be `final` only, or they overlook that a sealed class can be concrete and does not need to be abstract.
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
✓
A sealed class restricts which other classes or interfaces may extend or implement it.
The primary purpose of the sealed class feature is to explicitly control which other classes or interfaces are permitted to extend or implement it. This is achieved by using the `permits` clause to list the allowed subclasses, thereby restricting the inheritance hierarchy.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
A sealed class restricts which other classes or interfaces may extend or implement it.
Why this is correct
This statement is true because a sealed class restricts which classes may extend it by using the `permits` clause to list the allowed subclasses.
- ✗
A sealed interface cannot use the permits clause.
Why it's wrong here
This statement is false because a sealed interface can indeed use the `permits` clause to specify which classes can implement it.
- ✓
A subclass of a sealed class must be declared as final, sealed, or non-sealed.
Why this is correct
This statement is correct. Any subclass of a sealed class must be declared with one of three modifiers: `final`, `sealed`, or `non-sealed`.
- ✗
The permits clause must list all direct subclasses of a sealed class.
Why it's wrong here
This statement is false. The `permits` clause is not mandatory if the sealed class and its direct subclasses are declared in the same compilation unit. Additionally, even when used, it must list all permitted subclasses, but it is not always required.
- ✗
A sealed class must be declared as abstract.
Why it's wrong here
This statement is false. A sealed class can be concrete (non-abstract). For example, a sealed class can be instantiated.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
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.