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 Test
{
public static void main(String[] args)
{
Zi z = new Zi();//fu zi
z.show();
}
}
zi z是先访问Test 类,然后在访问静态的main方法,于是就加载了父类静态的方法,然后加载了子类静态的方法,
然后new Zi()是在堆里面开辟了一个内存,把地址值给了Zi z,然后访问无参Zi()的构造方法,但是默认的super();
于是访问了无参的父类构造方法..z.show ();子类调用show()方法,然后输出!