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

What is 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 constructor calls super with two parameters while the Fruit constructor accepts only one parameter.

B

The parameter types in the Fruit constructor are incompatible with those in Banana.

C

The Banana class should not extend Fruit.

D

The Banana constructor should call this() instead of super().

Check Answer
APFIVE © 2020.
Email: [email protected]|Privacy Policy