| 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 1 students
Interface Method Overriding
< Prev
Next >

Consider the following code. What is printed when the main method of the Car class is executed?

interface Vehicle {
    default String type() {
        return "Vehicle";
    }
}

class Car implements Vehicle {
    public String type() {
        return "Car";
    }
    
    public static void main(String[] args) {
        Vehicle v = new Car();
        System.out.println(v.type());
    }
}
A

Compilation Error

B

Car

C

Vehicle

D

Runtime Error

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