博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
7-1 程序填空题2 (12分)
阅读量:4035 次
发布时间:2019-05-24

本文共 861 字,大约阅读时间需要 2 分钟。

补全以下程序,使得程序输出结果与下述结果一致。

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!

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){
this(); System.out.println("Constructor two invoked!"); } public Test(boolean b){
this(1); System.out.println("Constructor three invoked!"); }}

转载地址:http://aqbdi.baihongyu.com/

你可能感兴趣的文章
【leetcode】Candy(python)
查看>>
【leetcode】Clone Graph(python)
查看>>
【leetcode】Sum Root to leaf Numbers
查看>>
【leetcode】Pascal's Triangle II (python)
查看>>
java swing最简单实例(2) 往JFrame里面放一个容器或组件
查看>>
java自定义容器排序的两种方法
查看>>
如何成为编程高手
查看>>
本科生的编程水平到底有多高
查看>>
AngularJS2中最基本的文件说明
查看>>
从头开始学习jsp(2)——jsp的基本语法
查看>>
从头开始学习JSP(3)——一些配置
查看>>
html常用标签快速检索
查看>>
使用与或运算完成两个整数的相加
查看>>
备忘:java中的递归
查看>>
DIV/CSS:一个贴在左上角的标签
查看>>
通过/proc/PID/status查看进程内存占用情况
查看>>
/proc文件系统读出来的数据是最新的吗?
查看>>
Solr及Spring-Data-Solr入门学习
查看>>
Vue组件
查看>>
python_time模块
查看>>