nerdexam
Oracle

1Z0-808 · Question #17

1Z0-808 Question #17: Real Exam Question with Answer & Explanation

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

Working with Methods and Encapsulation

Question

Given the code fragment: public class Person { String name; int age = 25; public Person(String name) { //line n1 this(); setName(name); } public Person(String name, int age) { //line n2 Person(name); setAge(age); } //setter and getter methods go here public String show() { return name + " " + age + " " + number; } public static void main(String[] args) { Person p1 = new Person("Walter", 52); Person p2 = new Person("Jesse"); System.out.println(p1.show()); System.out.println(p2.show()); } } What is the result?

Options

  • AJesse 25 Walter 52
  • BCompilation fails only at line n1
  • CCompilation fails only at line n2
  • DCompilation fails at both line n1 and line n2

Unlock 1Z0-808 to see the answer

You've previewed enough free 1Z0-808 questions. Unlock 1Z0-808 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

#constructor invocation#this() keyword#constructor chaining#compilation errors
Full 1Z0-808 Practice