class People {
public String toString() {
return "I am a people!";
}
public void eat() {
};
public void speak() {
};
}
class Boy extends People {
public String toString() {
return "I am a boy!";
}
public void fight() {
};
public void speak() {
};
}
class Girl extends People {
public String toString() {
return "I am a girl!";
}
public void sing() {
};
public void speak() {
};
}
public class TestToString {
public static void main(String args[]) {
People p = new Girl();
System.out.println(p.toString());
}
}
I am a girl!
class A {
public String show(D obj) {
return "A and D";
}
public String show(A obj) {
return "A and A";
}
}
class B extends A {
public String show(B obj) {
return "B and B";
}
public String show(A obj) {
return "B and A";
}
}
class C extends B {
}
class D extends B {
}
public class Main {
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(a1.show(b)); // 1
System.out.println(a1.show(c)); // 2
System.out.println(a1.show(d)); // 3
System.out.println(a2.show(b)); // 4
System.out.println(a2.show(c)); // 5
System.out.println(a2.show(d)); // 6
System.out.println(b.show(b)); // 7
System.out.println(b.show(c)); // 8
System.out.println(b.show(d)); // 9
}
}
A and A A and A A and D B and A B and A A and D B and B B and B A and D
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有