多态的问题
class B
{
static void run(){
System.out.println("B");
}
}
class D extends C
{
static void run(){
System.out.println("D");
}
}
class C extends B
{ static void run(){
System.out.println("c");
}
public static void main(String[] args)
{
B b1 = new B();
b1.run();
B b2 = new C();
b2.run();
B b3 = new D();
b3.run();
C c1 = new C();
c1.run();
C c2 = new D();
c2.run();
}
}
大家事先预测一下打印结果,再谈谈为什么会导致这样的原因!!!!