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