Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
easy Solved by 1 students

Subclass Default Constructor Implementation

Mark
< Prev
Next >

Consider 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 code segments, if substituted for /* implementation not shown */, correctly implements the default constructor for the Dog class?

I. super(1.0); breed = "Unknown";
II. breed = "Unknown"; super();
III. super(); breed = "Unknown";

A

II only

B

III only

C

I, II, and III

D

I 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.

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|