nerdexam
Oracle

1Z0-808 · Question #42

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

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

Working with Inheritance

Question

Given:
class Vehicle {
 String type = "4W";
 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 = trans;
 }
}
And given the code fragment:
7. Car c1 = new Car("Auto");
8. Car c2 = new Car("4W", 150, "Manual");
9. System.out.println(c1.type + " " + c1.maxSpeed + " " + c1.trans);
10. System.out.println(c2.type + " " + c2.maxSpeed + " " + c2.trans);
What is the result?

Options

  • A4W 100 Auto
  • B4W 150 Manual
  • CNull 0 Auto
  • D4W 150 Manual
  • ECompilation fails only at line n1
  • FCompilation 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

#Implicit super()#Constructor chaining#Inheritance#No-arg constructor
Full 1Z0-808 Practice
Given: java class Vehicle { String type = "4W"; int maxSpeed =... | 1Z0-808 Q#42 Answer | NerdExam