Java练习题1(有答案)(7)
4、 The program runs and prints 2 followed by \int)\is invoked.
5、 The program runs and prints \by 2. 答案 2 第 73题 The client can use a method without knowing how it is implemented. The details of the implementation are encapsulated in the method and hidden from the client who invokes the method. This is known as __________. 1、 information hiding 2、 encapsulation 3、 method hiding
4、 simplifying method 答案 1 2 第 74
题 What is
Math.floor(3.6)? 1、 3.0 2、 3
3、 4 4、 5.0 答案 1 第 75题 If you declare an array double[] list = {3.4, 2.0, 3.5, 5.5}, list[1] is ________. 1、 3.4 2、 2.0 3、 3.4
4、 5.5 5、 undefined 答案 2 第 76题 If you declare an array double[] list = {3.4, 2.0, 3.5, 5.5}, the highest index in array list is __________. e, 4 1、 0 2、 1
3、 2 4、 3 答案 4 第 77题 Suppose int i = 5, which of the following can be used as an index for array double[] t = new double[100]? 1、 i
2、 (int)(Math.random() * 100)) 3、 i + 10 4、 i + 6.5
5、 Math.random() * 100 答案 1 2 3 第 78题 Analyze the following code. public class Test { public static void main(String[] args) { int[] x = new int[3];
System.out.println(\ }
}
1、 The program has a compile error because the size of the array wasn t specified when declaring the array.
2、 The program has a runtime error because the array elements are not initialized.
3、 The program runs fine and displays x[0] is 0.
4、 The program has a runtime error because the array element x[0] is not defined. 答案 3 第 79题 What would be the result of attempting to compile and run the following code? public class Test { public static void main(String[] args) { double[] x = new double[]{1, 2, 3}; System.out.println(\ } }
1、 The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by {1, 2, 3}.
2、 The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[3]{1, 2, 3}; 3、 The program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[]{1.0, 2.0, 3.0}; 4、 The program compiles and runs fine and the output \printed.
5、 The program compiles and runs fine and the output \is 2.0\答案 5 第 80题 Analyze the following code: public class Test { public static void main(String[] args) { int[] x = new int[5];
int i; for (i = 0; i < x.length; i++) x[i] = i;
System.out.println(x[i]); } }
1、 The program displays 0 1 2 3 4. 2、 The program displays 4.
3、 The program has a runtime error because the last statement in the main method causes ArrayIndexOutOfBoundsException.
4、 The program has a compile error because i is not defined in the last statement in the main method.
答案 3 第 81题 In the following code, what is the printout for list2?
class Test { public static void
main(String[] args) { int[] list1 = {1, 2, 3}; int[] list2 = {1, 2, 3}; list2 = list1; list1[0] = 0; list1[1] = 1; list2[2] = 2; for (int i = 0; i < list2.length; i++)
System.out.print(list2[i] + \ } }
1、 1 2 3 2、 1 1 1 3、 0 1 2
4、 0 1 3 答案 3 第 82题 In the following code, what is the printout for list1? class Test { public static void
main(String[] args) { int[] list1 = {1, 2, 3}; int[] list2 = {1, 2, 3}; list2 = list1; list1[0] = 0; list1[1] = 1; list2[2] = 2; for (int i = 0; i < list1.length; i++)
System.out.print(list1[i] + \ } }
1、 1 2 3 2、 1 1 1
3、 0 1 2 4、 0 1 3 答案 3 第 83题 Analyze the following code: public class Test { public static void main(String[] args) { int[] x = {1, 2, 3, 4}; int[] y = x; x = new int[2]; for } }
1、 The program displays 1 2 3 4 2、 The program displays 0 0
(int
i
=
0;
i
<
x.length;
i++)
System.out.print(x[i] + \
3、 The program displays 0 0 3 4 4、 The program displays 0 0 0 0 答案 2 第 84题 Analyze the following code: public class Test { public static void main(String[] args) { final int[] x = {1, 2, 3, 4}; int[] y = x; x = new int[2];
for (int i = 0; i < y.length; i++) System.out.print(y[i] + \ } }
1、 The program displays 1 2 3 4 2、 The program displays 0 0
3、 The program has a compile error on the statement x = new int[2], because x is final and cannot be changed.
4、 The elements in the array x cannot be changed, because x is final. 答案 3 第 85题 Analyze the following code: public class Test { public static void main(String[] args) { int[] a = new int[4]; a[1] = 1; a = new int[2];
System.out.println(\ } }
1、 The program has a compile error because new int[2] is assigned to a. 2、 The program has a runtime error because a[1] is not initialized. 3、 The program displays a[1] is 0. 4、 The program displays a[1] is 1. 答案 3 第 86题 Show the output of the following code: public class Test { public static void main(String[] args) { int[] x = {1, 2, 3, 4, 5}; increase(x); int[] y = {1, 2, 3, 4, 5}; increase(y[0]);
System.out.println(x[0] + \ } public static void increase(int[] x) { for (int i = 0; i < x.length; i++) x[i]++; } public static void increase(int y) { y++; } } 1、 0 0 2、 1 1 3、 2 2
4、 2 1 5、 1 2 答案 4 第 87题 programs produce the same result? Program I:
public class Test { public static void main(String[] args) { int[] list = {1, 2, 3, 4, 5}; reverse(list);
for (int i = 0; i < list.length; i++) System.out. …… 此处隐藏:3284字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [实用模板]第八章:法国“新浪潮”与“左岸派”
- [实用模板]2021年北京上半年临床医学检验技师生物
- [实用模板]SAP GUI 7.10客户端安装配置文档
- [实用模板]2001年临床执业医师资格考试综合笔试试
- [实用模板]36机场工作实用英语词汇总结
- [实用模板](一)社会保险稽核通知书
- [实用模板]安全教育主题班会材料
- [实用模板]濉溪县春季呼吸道传染病防控应急演练方
- [实用模板]长沙房地产市场周报(1.30-2.3)
- [实用模板]六年级数学上册典中点 - 图文
- [实用模板]C程序设计(红皮书)习题官方参考答案
- [实用模板]中国证监会第一届创业板发行审核委员会
- [实用模板]桥梁工程复习题
- [实用模板]2011学而思数学及答案
- [实用模板]初中病句修改专项练习
- [实用模板]监理学习知识1 - 图文
- [实用模板]小机灵杯四年级试题
- [实用模板]国贸专业毕业论文模板
- [实用模板]教育学概论考试练习题-判断题4
- [实用模板]2015届高考英语一轮复习精品资料(译林
- 00Nkmhe_市场营销学工商管理_电子商务_
- 事业单位考试法律常识
- 诚信教育实施方案
- 吉大小天鹅食品安全检测箱方案(高中低
- 房地产销售培训资料
- 高一地理必修1复习提纲
- 新概念英语第二册lesson_1_练习题
- 证券公司内部培训资料
- 小学英语时间介词专项练习
- 新世纪英语专业综合教程(第二版)第1册U
- 【新课标】浙教版最新2018年八年级数学
- 工程建设管理纲要
- 外研版 必修一Module 4 A Social Surve
- Adobe认证考试 AE复习资料
- 基于H.264AVC与AVS标准的帧内预测技术
- 《食品检验机构资质认定管理办法》(质
- ABB变频器培训课件
- (完整版)小学说明文阅读练习题及答案
- 深思洛克(SenseLock) 深思IV,深思4,深
- 弟子规全文带拼音




