Oracle
1Z0-808 · Question #12
1Z0-808 Question #12: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-808 to reveal the answer and full explanation for question #12. The question stem and answer options stay visible for context.
Question
Given:
class Vehicle {
int x;
Vehicle() {
this(10); // line n1
}
Vehicle(int x) {
this.x = x;
}
}
class Car extends Vehicle {
int y;
Car() {
super();
this(20); // line n2
}
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.y);
What is the result?
Options
- A10:20
- B0:20
- CCompilation fails at line n1
- DCompilation fails at 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.