}
public class D extends C{
public void f()
{
System.out.printf("DDD\n");
}
}
public class Exercise2 {
public static void g(C cc)
{
cc.f();
}
public static void main(String[] args) {
D dd1=new D();
C cc1=new C();
g(cc1);
g(dd1);
}
}
原文:https://blog.51cto.com/13930723/2355866