###09.08_面向对象(多态中的题目分析题)
* A:看下面程序是否有问题,如果没有,说出结果
*
class Fu {
public void show() {
System.out.println("fu show");
}
}
class Zi extends Fu {
public void show() {
System.out.println("zi show");
}
public void method() {
System.out.println("zi method");
}
}
class Test1Demo {
public static void main(String[] args) {
Fu f = new Zi();
// f.method();
f.show();
}
}
* B:看下面程序是否有问题,如果没有,说出结果
*
class A {
public void show() {
show2();
}
public void show2() {
System.out.println("我");
}
}
class B extends A {
public void show2() {
System.out.println("爱");
}
}
class C extends B {
public void show() {
super.show();
}
public void show2() {
System.out.println("你");
}
}
public class Test2DuoTai {
public static void main(String[] args) {
A a = new B();
a.show();