
解析:
A、构造方法没有返回值,没有返回值和返回值为void是两码事
B、正确,如果没有写构造方法,会默认创建一个空的构造方法
C、重载的构造方法可以相互调用,通过this(参数); 进行调用;
如下:
/*** 测试构造方法之间的相互调用*/public class TestConstructor1 {String name;public TestConstructor1() {this("HelloWorld");}public TestConstructor1(String name) {this.name = name;}public static void main(String[] args) {TestConstructor1 testConstructor1 = new TestConstructor1();System.out.println(testConstructor1.name);}}
输出:
D、子类可以调用父类的构造方法,通过super调用。
