| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
Share
About Exam
medium Solved by 3 students
Subclass Constructor Implementation
< 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 only

B

I and III only

C

II and III only

D

III only

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

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