| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice Test
Share
easy Solved by 3 students
Subclass Constructor Super Call
< Prev
Next >

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().

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki11 0m 00s 100
#2psak1211 0m 42s 58
#3suhanakochhar00612 1m 42s -12
APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy