Oracle
1Z0-809 · Question #143
1Z0-809 Question #143: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #143. The question stem and answer options stay visible for context.
Question
Given:
class Vehicle {
String type;
int maxSpeed = 100;
Vehicle(String type, int maxSpeed) {
this.type = type;
this.maxSpeed = maxSpeed;
}
}
class Car extends Vehicle {
String trans;
Car(String trans) { //line n1
this.trans = trans;
}
Car(String type, int maxSpeed, String trans) { //line n2
super(type, maxSpeed);
this(trans);
}
}
And given the code fragment:
7. Car c1 = new Car("Auto");
8. System.out.println(c1.type + " " + c1.maxSpeed + " " + c1.trans);
9. Car c2 = new Car("Manual", 150, "Manual");
10. System.out.println(c2.type + " " + c2.maxSpeed + " " + c2.trans);
What is the output?Options
- Anull 0 Auto
- B4W 150 Manual
- CCompilation fails at both line n1 and line n2.
- DCompilation fails only at line n1.
- ECompilation fails only at line n2.
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 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.