Subclass Constructor Super Call
Consider the following class declarations. Which statement best explains the error in the Banana class constructor?
public class Fruit {
public Fruit(String type) { }
}
public class Banana extends Fruit {
public Banana() {
super("yellow", true);
}
}
A
The Banana class should not extend Fruit.
B
The parameter types in the Fruit constructor are incompatible with those in Banana.
C
The Banana constructor calls super with two parameters while the Fruit constructor accepts only one parameter.
D
The Banana constructor should call this() instead of super().
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 1 | 0m 00s | 100 |
| #2 | psak12 | 1 | 1 | 0m 42s | 58 |
| #3 | suhanakochhar006 | 1 | 2 | 1m 42s | -12 |
APFIVE