Courseiva
Question 190 of 513
Utilizing Java Object-Oriented ApproachhardMultiple ChoiceObjective-mapped

1Z0-829 Utilizing Java Object-Oriented Approach Practice Question

Exhibit

Refer to the exhibit.

sealed class Shape permits Circle, Square {
    abstract double area();
}

final class Circle extends Shape {
    double area() { return 0; }
}

non-sealed class Square extends Shape {
    double area() { return 0; }
}

class Triangle extends Shape { }

Which statement about the code is correct?

⚠ Common exam trap

The trap here is that candidates often overlook the requirement that every direct subclass of a sealed class must be explicitly listed in the `permits` clause, assuming that simply extending the sealed class is sufficient.

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 compilation error occurs in the Triangle class because Triangle is not listed in the permits clause.

In a sealed class hierarchy, the `permits` clause must list all direct subclasses. If `Triangle` extends `Shape` but is not listed in the `permits` clause of `Shape`, the compiler will report an error. The sealed class mechanism enforces that only explicitly permitted subclasses may extend the 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.

  • A compilation error occurs in the Triangle class because Triangle is not listed in the permits clause.

    Why this is correct

    Sealed classes require that all direct subclasses be listed in the permits clause.

  • A compilation error occurs because Circle must be declared final.

    Why it's wrong here

    Circle is already final; that is correct for a sealed class hierarchy.

  • A compilation error occurs because Shape must be declared abstract.

    Why it's wrong here

    Shape is already declared abstract; sealed classes can be abstract.

  • The code compiles successfully.

    Why it's wrong here

    The Triangle class causes a compilation error because it is not permitted.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jul 4, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.