class A{
public String s(D d){
return ("A and D");
}
public String s(A a){
return ("A and A");
}
}
class B extends A{
public String s(B b){
return ("B and B");
}
public String s(A a){
return ("B and A");
}
}
class C extends B{}
class D extends B{}
public class Test {
public static void main (String[] args){
A a1=new A();
A a2=new B();
B b=new B();
C c=new C();
D d=new D();
System.out.println(a2.s(b));
System.out.println(a2.s(c));
System.out.println(a2.s(d));
}
}
求解 为什么结果是
B and A
B and A
A and D |
|