nerdexam
Oracle

1Z0-829 · Question #45

1Z0-829 Question #45: Real Exam Question with Answer & Explanation

Sign in or unlock 1Z0-829 to reveal the answer and full explanation for question #45. The question stem and answer options stay visible for context.

Java Object-Oriented Approach

Question

Given the code fragment: Pet p = new Pet("Dog"); Pet p1 = p; p1.name = "Cat"; p = p1; System.out.println(p.name); p = null; System.out.println(p1.name); What is the result?

Options

  • ACat Dog
  • BA NullPointerException is thrown Cat Cat
  • CDog Dog
  • DCat Cat
  • ECat null

Unlock 1Z0-829 to see the answer

You've previewed enough free 1Z0-829 questions. Unlock 1Z0-829 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#object references#reference aliasing#mutable state#null assignment
Full 1Z0-829 Practice