下面是People和Child类的定义和构造方法,每个构造方法都输出编号。在执行new Child("mike")的时候都有哪些构造方法被顺序调用?请选择输出结果 ( D )
class People {
String name;
public People() { System.out.print(1); }
public People(String name) {
System.out.print(2);
this.name = name; }
}
class Child extends People {
People father;
public Child(String name) {
System.out.print(3);
this.name = name;
father = new People(name + ":F"); }
public Child(){ System.out.print(4); }
}
A)312 B) 32 C) 432 D) 132
弑天下
翻阅古今
相关分类