packageclassTest;classFather{publicFather(){System.out.println("父类的无参构造方法");}publicFather(int a ){System.err.println("父类的有参构造方法"+a);}}classSonextendsFather{publicSon(){System.out.println("子类中的无参构造方法");}publicSon(int a ){System.out.println("子类中的有参构造方法"+a);}}publicclassTestExecute{publicstaticvoidmain(String[] args){Son s =newSon();System.out.println("==============");Son a =newSon(111);}}
结果:
父类的无参构造方法
子类中的无参构造方法
==============
父类的无参构造方法
子类中的有参构造方法111