interface Vehicle
{
public abstract void getVehicle();
}
public class HelloWorld implements Vehicle{
@Override
public void getVehicle()
{
System.out.println("HelloWorld Implementation");
}
}
class MyWorld extends HelloWorld implements Vehicle
{
@Override
public void getVehicle()
{
System.out.println("MyWorld Implementation");
}
}
当两个类都实现了抽象方法getVehicle()
时,实际上会发生什么?子类是否覆盖了超类的getVehicle()
,还是接口的getVehicle()
?