| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
easy Solved by 3 students
Subclass Default Constructor Implementation
< Prev
Next >

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

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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