Java练习题1(有答案)(4)
System.out.print(ch); break; case c : case C :
System.out.print(ch); break; case d : case D : System.out.print(ch); }
1、 abcd 2、 a 3、 aa
4、 ab 5、 abc 答案 2 第 47题 What is the printout of the following switch statement? char ch = b ; switch
(ch)
{ case a :
System.out.print(ch); case b :
System.out.print(ch); case c :
System.out.print(ch); case d :
System.out.print(ch); }
1、 abcd 2、 bcd 3、 b 4、 bb
5、 bbb 答案 5 第 48题 Analyze the following program fragment: int x; double d = 1.5; switch (d) { case 1.0: x = 1; case 1.5: x = 2; case 2.0: x = 3; }
1、 The program has a compile error because the required break statement is missing in the switch statement.
2、 The program has a compile error because the required default case is missing in the switch statement.
3、 The switch control variable cannot be double.
4、 No errors. 答案 3
第 49题 Analyze the following code fragments that assign a boolean value to the variable even. Code 1: if (number % 2 == 0) even = true; else even = false; Code 2:
even = (number % 2 == 0) ? true: false; Code 3: even = number % 2 == 0;
1、 Code 2 has a compile error, because you cannot have true and false literals in the conditional expression.
2、 Code 3 has a compile error, because you attempt to assign number to even.
3、 All three are correct, but Code 1 is preferred. 4、 All three are correct, but Code 2 is preferred. 5、 All three are correct, but Code 3 is preferred.
答案 5 第 50题 The statement System.out.printf(\1234.56) outputs ___________. 1、 0.1e+04 2、 0.123456e+04 3、 0.123e+04
4、 1.2e+03 5、 1.23+03 答案 4 第 51题 Analyze the following code: int i = 3434; double d = 3434; System.out.printf(\
1、 The code compiles and runs fine to display 3434.0 3434.0. 2、 The code compiles and runs fine to display 3434 3434.0.
3、 i is an integer, but the format specifier %5.1f specifies a format for double value. The code has an error.
答案 3 第 52题 What is the value of the following expression?
true || true && false 1、 true
2、 false 答案 1 第 53题 Which of the following statements are true? 1、 (x > 0 && x < 10) is same as ((x > 0) && (x < 10))
2、 (x > 0 || x < 10) is same as ((x > 0) || (x < 10))
3、 (x > 0 || x < 10 && y < 0) is same as (x > 0 || (x < 10 && y < 0)) 4、 (x > 0 || x < 10 && y < 0) is same as ((x > 0 || x < 10) && y < 0) 答案 1 2 3 第 54题 How many times will the following code print \ int count = 0; while (count < 10) {
System.out.println(\count++; } 1、 8 2、 9 3、 10
4、 11 5、 0 答案 3 第 55题 Analyze the following code. int count = 0; while (count < 100) { // Point A
System.out.println(\count++; // Point B }
// Point C
1、 count < 100 is always true at Point A 2、 count < 100 is always true at Point B 3、 count < 100 is always false at Point B
4、 count < 100 is always true at Point C 5、 count < 100 is always false at Point C 答案 1 5 第 56题 How many times will the following code print \ int count = 0; do {
System.out.println(\ } while (count++ < 10); 1、 8 2、 9 3、 10
to
Java!\
to
Java\
4、 11 5、 0 答案 4 第 57题 What is the value in count after the following loop is executed? int count = 0; do {
System.out.println(\ } while (count++ < 9); System.out.println(count); 1、 8 2、 9 3、 10
4、 11 5、 0 答案 3 第 58题 Do the following two statements in (I) and (II) result in the same value in sum? (I): for (int i = 0; i<10; ++i) { sum += i;
} (II): for (int i = 0; i<10; i++) { sum += i; }
1、 Yes 2、 No 答案 1 第 59题 Is the following loop correct? for (; ; ); 1、 Yes 2、 No 答案 1 第 60题 Analyze the following code: public class Test { public static void main (String args[]) { int i = 0; for
(i
=
0;
i
<
10;
i++);
System.out.println(i + 4); } }
1、 The program has a compile error because of the semicolon (;) on the for loop line.
2、 The program compiles despite the semicolon (;) on the for loop line, and displays 4.
3、 The program compiles despite the semicolon (;) on the for loop line, and displays 14.
4、 The for loop in this program is same as for (i = 0; i < 10; i++) { }; System.out.println(i + 4); 答案 3 4
…… 此处隐藏:1226字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [实用模板]第八章:法国“新浪潮”与“左岸派”
- [实用模板]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,深
- 弟子规全文带拼音




