Java练习题1(有答案)(5)
第 61题 To add 0.01 + 0.02 + ... + 1.00, what order should you use to add the numbers to get better accuracy?
1、 add 0.01, 0.02, ..., 1.00 in this order to a sum variable whose initial value is 0.
2、 add 1.00, 0.99, 0.98, ..., 0.02, 0.01 in this order to a sum variable whose initial value is 0.
答案 1 第 62题 What is sum after the following loop terminates? int sum = 0; int item = 0; do { item++; sum += item; if (sum > 4) break;
} while (item < 5); 1、 5 2、 6
3、 7 4、 8 答案 2 第 63题 After the continue outer statement is executed in the following loop, which statement is executed? outer: for (int i = 1; i < 10; i++) { inner:
for (int j = 1; j < 10; j++) { if (i * j > 50) continue outer; System.out.println(i * j); } } next:
1、 The control is in the outer loop, and the next iteration of the outer loop is executed.
2、 The control is in the inner loop, and the next iteration of the inner loop is executed.
3、 The statement labeled next.
4、 The program terminates. 答案 1 第 64题 Suppose the input for number is 9. What is the output from running the following program? import java.util.Scanner; public class Test {
public static void main(String[] args) { Scanner input = new Scanner(System.in);
System.out.print(\int number = input.nextInt(); int i;
boolean isPrime = true; for (i = 2; i < number && isPrime; i++) { if (number % i == 0) { isPrime = false; } }
System.out.println(\if (isPrime)
System.out.println(number + \is prime\else
System.out.println(number + \ } }
1、 i is 3 followed by 9 is prime 2、 i is 3 followed by 9 is not prime
3、 i is 4 followed by 9 is prime 4、 i is 4 followed by 9 is not prime 答案 4 第 65题 Suppose your method does not return any value, which of the following keywords can be used as a return type? 1、 void 2、 int 3、 double 4、 public
5、 None of the above 答案 1 第 66题 All Java applications must have a method __________. 1、 public static Main(String[] args) 2、 public static Main(String args[]) 3、 public static void main(String[] args)
4、 public void main(String[] args) 5、 public static main(String[] args) 答案 3 第 67题 Does the return statement in the following method cause compile errors?
public static void main(String[] args) { int max = 0; if (max != 0) System.out.println(max); else return; }
1、 Yes 2、 No 答案 2 第 68题 Does the method call in the following method cause compile errors?
public static void main(String[] args) { Math.pow(2, 4); }
1、 Yes 2、 No 答案 2 第 69题 Suppose
static void nPrint(String message, int n) { while (n > 0) {
System.out.print(message); n--; } }
What is the printout of the call nPrint( a , 4)? 1、 aaaaa 2、 aaaa 3、 aaa
4、 invalid call 答案 4 第 70题 Suppose
static void nPrint(String message, int n) { while (n > 0) {
System.out.print(message); n--; } }
What is k after invoking nPrint(\ int k = 2; nPrint(\message\ 1、 0 2、 1
3、 2 4、 3 答案 3 第 71题 Analyze the following code: public class Test { public static void main(String[] args) {
System.out.println(xMethod(5, 500L)); }
public static int xMethod(int n, long l) {
System.out.println(\
long\
return n; }
public static long xMethod(long n, long l) { } }
1、 The program displays int, long followed by 5. 2、 The program displays long, long followed by 5.
3、 The program runs fine but displays things other than 5.
4、 The program does not compile because the compiler cannot distinguish which xmethod to invoke. 答案 1 第 72题 Analyze the following code. public class Test { public static void main(String[] args) { System.out.println(max(1, 2)); }
public static double max(int num1, double num2) {
System.out.println(\ …… 此处隐藏:1409字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [实用模板]第八章:法国“新浪潮”与“左岸派”
- [实用模板]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,深
- 弟子规全文带拼音




