2.父类无参构造函数一定被调用
class Father{ public Father(){ System.out.println("FatherGouzao"); } public Father(int x){ System.out.println("Father x="+ x); } public void Sub_1() { System.out.println("Father Sub_1"); }}public class Son extends Father{ public Son(){ System.out.println("SonGouzao"); } public Son(int x){ super(x); System.out.println("Son x="+ x); } public void Sub_1(){ System.out.println("Son Sub_1"); } public void Sub_1(int x){ System.out.println("Son Sub_1 x="+x); } public static void main(String[] args) { // TODO Auto-generated method stub Son Object = new Son(1); Object.Sub_1(); Object.Sub_1(2); }}输出: Father x=1 Son x=1 Son Sub_1 Son Sub_1 x=2