* A:案例演示
*
看程序写结果1
class Fu{
public int num = 10;
public Fu(){
System.out.println("fu");
}
}
class Zi extends Fu{
public int num = 20;
public Zi(){
System.out.println("zi");
}
public void show(){
int num = 30;
System.out.println(num);
System.out.println(this.num); //调用本类的成员变量,不是局部变量
System.out.println(super.num); //调用父类的成员变量
}
}
class Test1_Extends {
public static void main(String[] args) {
Zi z = new Zi();
z.show();
}
}
输出结果:fu, zi,30,20,10 |
|