/**
*测试这个程序,测试对象类型的动态绑定
*/
public class ObjectVarTest
{
public static void main(String[] args){
B b=new B();
C.method3(b);
}
}
class A{
public void method1(){
System.out.println("this is class A method1");
}
}
class B extends A{
public void method1(){
System.out.println("this is class B method1");
public void method2(){
System.out.println("this is class B method2");
}
}
class c{
public static void method3(A a){
a.method1();
}}
}