30.下面是People和Child类的定义和构造方法,每个构造方法都输出编号。在执行new Child("mike")的时候都有哪些构造方法被顺序调用?请选择输出结果 ( )
- 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);
- }
-
- }
复制代码
|
|