#PTAOOP514. 5-14 sdut-oop-1-测试对象初始化(构造方法)
5-14 sdut-oop-1-测试对象初始化(构造方法)
本站提交说明
此题属于 面向对象程序设计练习。请在练习页填写原题的填空或函数片段并提交;本题独立提交页接收拼接后的完整 Java 程序。
评测使用题面样例与本站补充测试,包含编译、输出及部分成员 API 检查。通过本站测试不代表通过 PTA 隐藏测试。
阅读程序,补全以下程序:
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!