Courseiva
Utilizing Java Object-Oriented ApproachmediumMultiple ChoiceObjective-mapped

1Z0-829 Sealed Interface Practice Question

Exhibit

sealed class Shape permits Circle, Rectangle {
    void draw() { System.out.println("Shape"); }
}
non-sealed class Circle extends Shape {
    void draw() { System.out.println("Circle"); }
}
final class Rectangle extends Shape {
    void draw() { System.out.println("Rectangle"); }
}
class Triangle extends Shape {  // Line 10
    void draw() { System.out.println("Triangle"); }
}

Refer to the exhibit. Given the following code:

```java 1: sealed interface Shape permits Circle { } ... 10: class Circle implements Shape { } ```

What is the result?

⚠ Common exam trap

Candidates often overlook the mandatory modifier (`sealed`, `non-sealed`, or `final`) on each permitted subclass of a sealed type. Even if the class is logically final (e.g., all methods are final or the class is implicitly final), the Java compiler requires an explicit keyword.

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

Compilation fails at line 10

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.

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 →

How Courseiva writes practice questions · Editorial policy

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.