| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
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

III only

B

II and III only

C

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

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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