Interface Method Overriding
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
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE