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

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
Report Question
Mark for review

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|