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
medium Solved by 2 students

Subclass Constructor Implementation

Mark
< Prev
Next >

Consider the following class definitions.

public class Vehicle {
    private int speed;
    public Vehicle() {
        speed = 0;
    }
    public Vehicle(int s) {
        speed = s;
    }
    // Other methods not shown
}

public class Car extends Vehicle {
    private String model;
    public Car(int s, String m) {
        /* implementation not shown */
    }
    // Other methods not shown
}

Which of the following code segments correctly implements the Car constructor?

I. super(s); this.model = m;
II. super(); speed = s; model = m;
III. super(s); model = m;

A

I and III only

B

II and III only

C

III only

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|