Java Inheritance and Constructors
Consider the following class declarations.
public class FruitBasket {
private int appleCount;
FruitBasket () {
appleCount = 1;
}
FruitBasket(int count) {
appleCount = count;
}
public int getAppleCount () {
return appleCount;
}
}
public class AppleBag extends FruitBasket {
AppleBag () {
super(3);
}
}
Which of the following code segments will compile without error?
A
FruitBasket f1 = new AppleBag(2);
B
AppleBag a2 = new FruitBasket();
C
AppleBag a1 = new AppleBag(4);
D
FruitBasket f2 = new AppleBag();
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE