Subclass Default Constructor Implementation
Consider the following class definitions.
public class Animal {
private int age;
public Animal() {
age = 0;
}
public Animal(int a) {
age = a;
}
// Other methods not shown
}
public class Dog extends Animal {
private String breed;
public Dog() {
/* implementation not shown */
}
// Other methods not shown
}
Which of the following code segments, if substituted for /* implementation not shown */, correctly implements the default constructor for the Dog class?
I. super(1.0); breed = "Unknown";
II. breed = "Unknown"; super();
III. super(); breed = "Unknown";
A
II only
B
III only
C
I, II, and III
D
I only
Question Leaderboard
Not enough data yet to show leaderboard.
