Java练习题1(有答案)(2)
第 26题 Suppose x is 1. What is x after x -= 1? 1、 0 2、 1 3、 2
4、 -1 5、 -2 答案 1 第 27题 What is x after the following statements? int x = 1; int y = 2; x *= y + 1; 1、 x is 1; 2、 x is 2;
3、 x is 3; 4、 x is 4; 答案 3 第 28题 What is y displayed?
public class Test { public static void main(String[] args) { int x = 1; int y = x + x++; System.out.println(\+ y); } }
1、 y is 1. 2、 y is 2. 3、 y is 3.
4、 y is 4. 答案 2 第 29题 What is y displayed in the following code?
public class Test { public static void main(String[] args) { int x = 1; int y = x++ + x; System.out.println(\+ y); } }
1、 y is 1. 2、 y is 2.
3、 y is 3. 4、 y is 4. 答案 3 第 30题 What is the printout of the following code: double x = 5.5; int y = (int)x;
System.out.println(\ 1、 x is 5 and y is 6 2、 x is 6.0 and y is 6.0 3、 x is 6 and y is 6
4、 x is 5.5 and y is 5 5、 x is 5.5 and y is 5.0 答案 4 第 31题 Suppose x is a char variable with a value b . What is the printout of the statement System.out.println(++x)? 1、 a 2、 b
3、 c 4、 d 答案 3 第 32题 Suppose i is an int type variable. Which of the following statements display the character whose Unicode is stored in variable i?
1、 System.out.println(i); 2、 System.out.println((char)i);
3、 System.out.println((int)i); 4、 System.out.println(i + \答案 2 第 33题 The following code fragment reads in two numbers: Scanner input = new Scanner(System.in); int i = input.nextInt(); double d = input.nextDouble(); What are the correct ways to enter these two numbers?
1、 Enter an integer, a space, a double value, and then the Enter key. 2、 Enter an integer, two spaces, a double value, and then the Enter key. 3、 Enter an integer, an Enter key, a double value, and then the Enter key. 4、 Enter a numeric value with a decimal point, a space, an integer, and then the Enter key. 答案 1 2 3 第 34题 If you enter 1 2 3, when you run this program, what will be the output? import
java.util.Scanner;
public class Test1 {
public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print(\double number1 = input.nextDouble(); double number2 = input.nextDouble(); double number3 = input.nextDouble();
// Compute average double average = (number1 + number2 + number3) / 3; // Display result System.out.println(average); }
} 1、 1.0 2、 2.0 3、 3.0
4、 4.0 答案 2 第 35题 The expression (int)(76.0252175 * 100) / 100 evaluates to _________. 1、 76.02 2、 76
3、 76.0252175 4、 76.03 答案 2 第 36题 According to Java naming convention, which of the following names can be variables? 1、 FindArea 2、 findArea 3、 totalLength 4、 TOTAL_LENGTH
5、 class 答案 2 3 第 37题 The __________ method displays an input dialog for reading a string.
1、 String string = JOptionPane.showMessageDialog(null, \ \
2、 String string = JOptionPane.showInputDialog(null, \ \
3、 String string = JOptionPane.showInputDialog(\Demo\
4、 String string = JOptionPane.showInputDialog(null, \ 5、 String string = JOptionPane.showInputDialog(\a string\答案 2 4 5 第 38题 Analyze the following code. import javax.swing.*; public class ShowErrors { public static void main(String[] args) { int i; int j;
String s = JOptionPane.showInputDialog(null, \ JOptionPane.QUESTION_MESSAGE); j = Integer.parseInt(s);
i = (i + 4); } }
1、 The program cannot compile because j is not initialized.
2、 The program cannot compile because i does not have an initial value when it is used in i = i + 4;
3、 The program compiles but has a runtime error because i does not have an initial value when it is used in i = i + 4; 4、 The program compiles and runs fine. 答案 2 第 39题 Suppose x=10 and y=10. What is x after evaluating the expression (y > 10) && (x-- > 10)? 1、 9
2、 10 3、 11 答案 2 第 40题 Suppose x=10 and y=10 what is x after evaluating the expression (y >= 10) || (x++ > 10). 1、 9
2、 10 3、 11 答案 2 第 41题 Suppose x = 1, y = -1, and z = 1. What is the printout of the following statement? (Please indent the statement correctly first.) if (x > 0) if (y > 0) System.out.println(\> 0 and y > 0\else if (z > 0)
System.out.println(\ 1、 x > 0 and y > 0; 2、 x < 0 and z > 0; 3、 x < 0 and z < 0; 4、 no printout.
答案 2 第 42题 Analyze the following code. boolean even = false; if (even) {
System.out.println(\ }
1、 The code displays It is even! 2、 The code displays nothing.
3、 The code is wrong. You should replace if (even) with if (even == true) 4、 The code is wrong. You should replace if (even) with if (even = true) 答案 2 …… 此处隐藏:2321字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [实用模板]第八章:法国“新浪潮”与“左岸派”
- [实用模板]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,深
- 弟子规全文带拼音




