class Parent{
int num = 8;// ->3
Parent(){
//super(); // ->2
//显示初始化 // ->3
//构造代码段 // ->4
show(); // ->5
}
{// ->4
System.out.println("Parent constructor code run->");
}
public void show(){//被覆盖
System.out.println("num = " + num);
}
}
class Child extends Parent{
int num = 9;// ->6
Child(){
super();// ->1
//显示初始化 ->6
//构造代码段 ->7
num = 10; // ->8
System.out.println("after Child constructor code && Child constructor num = " + num);// ->9
}
{// ->7
System.out.println("Child constructor code run->");
System.out.println("after Child constructor num = " + num);
}
public void show(){
System.out.println("num = " + num);
}
}
public class PC{
public static void main(String[] args){
new Child();
}
}