1021课堂内容
一、动手实验。 1) 在子类调用时如果他是继承其父类时首先会先调用其父类的构造函数。 2) 调用关系修改Parent构造方法的代码,显式调用GrandParent的另一个构造函数,注意这句调用代码是否是第一句。 public class TestInherits { public static void main(String[] args) { Child c=new Child(); } } class Grandparent { public Grandparent() { System.out.println("GrandParent Created."); } public Grandparent(String string) { System.out.println("GrandParent Created.String:" + string); } } class Parent extends Grandparent { public Parent() { super("Parent Created"); //super("Hello.Grandparent."); System.out.println("Parent Created"); // super("Hello.Grandparent."); } } class Child extends