Subclass Default Constructor Implementation
Which of the following correctly implements the default constructor of the Dog class?
Refer to 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 correctly implements the default constructor of the Dog class?
I super(1.0); breed = "Unknown";
II breed = "Unknown"; super();
III super(); breed = "Unknown";
A
II only
B
I only
C
I, II, and III
D
III only
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE