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

Polymorphism and Method Overriding

Mark
< Prev
Next >

Consider the following class definitions. What is printed when the main method in the Main class is executed?

class Vehicle {
    public void start() {
        System.out.print("Vehicle is starting");
    }
}

class Car extends Vehicle {
    @Override
    public void start() {
        System.out.print("Car is starting");
    }
}

public class Main {
    public static void main(String[] args) {
        Vehicle v = new Car();
        v.start();
    }
}
A

Vehicle is starting

B

Vehicle is startingCar is starting

C

Compilation Error

D

Car is starting

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|