public class A {
public String Show(D obj) {
return "A and D";
}
public String Show(A obj) {
return "A and A";
}
}
public class B extends A{
public String Show(Object obj) {
return "B and B";
}
public String Show(A obj) {
return "B and A";
}
}
public class C extends B{
}
public class C 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("1---"+a1.Show(b));
System.out.println("2---"+a1.Show(c));
System.out.println("3---"+a1.Show(d));
System.out.println("4----"+a2.Show(b));
Syst