public class A {
String getV(){
return "A";
}
}
public class B extends A {
String getV(){
return "B";
}
public static void test(A a){
System.out.println(a.getV());
}
public static void test(B b){
System.out.println(b.getV());
}
public static void main(String[] arg){
A a = new A();
A b = new B();
test(b);
test(a);
}
}
In the testing, only test(A a ) will be invoked.
No comments:
Post a Comment