Subclass Constructor Implementation
Consider the following class definitions.
public class Vehicle {
private int speed;
public Vehicle() {
speed = 0;
}
public Vehicle(int s) {
speed = s;
}
// Other methods not shown
}
public class Car extends Vehicle {
private String model;
public Car(int s, String m) {
/* implementation not shown */
}
// Other methods not shown
}
Which of the following code segments correctly implements the Car constructor?
I. super(s); this.model = m;
II. super(); speed = s; model = m;
III. super(s); model = m;
A
I only
B
I and III only
C
II and III only
D
III only
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE