Courseiva
Utilizing Java Object-Oriented ApproachhardMultiple ChoiceObjective-mapped

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

Exhibit

public record Point(int x, int y) {
    public Point {
        if (x < 0 || y < 0) {
            throw new IllegalArgumentException();
        }
    }
    public int x() { return x; }
    public int y() { return y; }
}
public class Test {
    public static void main(String[] args) {
        Point p1 = new Point(1, 2);
        Point p2 = new Point(1, 2);
        System.out.println(p1.equals(p2));
        System.out.println(p1.x() == p2.x());
    }
}

Refer to the exhibit. What is the output?

⚠ Common exam trap

Oracle certification questions often test the distinction between `equals()` (content comparison) and `==` (reference comparison) with string literals, trapping candidates who assume `==` always returns `false` for distinct variables without considering string interning.

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

true true

The code uses `equals()` on two `String` objects with the same content ("Test"), which returns `true`. The second `println` uses `==` to compare the same two `String` references; since both reference the same string literal from the string pool, `==` also returns `true`. Thus both lines print `true`.

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 →

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.