-->
当前位置:首页 > 题库 > 正文内容

程序填空题:sdut-oop-1-测试对象初始化(构造方法)

Luz4年前 (2021-06-19)题库2111
阅读程序,补全以下程序:
```
public class Main {
    public static void main(String[] args) {
        Test test = new Test(true);
    }
}

class Test {
    public Test(){
        System.out.println("Constructor one invoked!");
    }
    public Test(int x){
     
     System.out.println("Constructor two invoked!");
    }
    public Test(boolean b){
       
        System.out.println("Constructor three invoked!");
    }
}
```

使得程序输出结果,如下所示。
```
Constructor one invoked!
Constructor two invoked!
Constructor three invoked!
```






答案: 第1空:this(); 第2空:this(0);


发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。