标题: 多态的执行 [打印本页] 作者: wuchangfeng 时间: 2015-7-19 09:43 标题: 多态的执行 class Fu
{
int i = 1;
int k =3;
public void eatFu(){
System.out.println("Fu eat");
}
public void run(){
System.out.println("Fu run");
}
}
class Zi extends Fu
{
int j = 1;
int k =3;
public void eatZi(){
System.out.println("Zi eat");
}
public void run(){
System.out.println("Zi run");
}
}
class DuoTaiDemo {
public static void main(String[] args) {
Fu f = new Zi();
System.out.println(f.i);
//System.out.println(f.j);
System.out.println(f.k);
//f.eatZi();
f.eatFu();
f.run();