class Fu {
public void show() {
System.out.println("fu show");
}
}
class Zi extends Fu {
public void show() {
System.out.println("zi show");
}
public void put() {
System.out.println("zi put");
}
}
public class Test {
public static void main(String[] args) {
Zi z = new Zi();
Fu fz = (Fu)z;//子类向上转型为父类类型
fz.show(); //子类提升为父类后,调用show方法 为什么 输出的是子类show方法?
}
}
|