nerdexam
Oracle

1Z0-809 · Question #128

1Z0-809 Question #128: Real Exam Question with Answer & Explanation

The correct answer is C. Compilation fails at line n2.. See the full explanation below for the reasoning.

Question

class Vehicle { int x; Vehicle() { this(10); // line n1 } Vehicle(int x) { this.x = x; } } class Car extends Vehicle { int y; Car() { super(); // line n2 this(20); } Car(int y) { this.y = y; } public String toString() { return super.x + ":" + this.y; } } And given the code fragment: Vehicle v = new Car(); System.out.println(v); What is the result?

Options

  • A0:20
  • B10:20
  • CCompilation fails at line n2.
  • DCompilation fails at line n1.

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice