ATA认证考(大部分呢) 下载本文

C. 022 D. 22H 答: ABC

41.下面的代码段中,执行之后i 和j 的值是 (第三章) int i = 2, j; j = i++; A. 1, 1 B. 1, 2 C. 2, 2 D. 3, 2 答: D

42.下面句话正确的是(第三章) A. >> 是算术右移操作符. B.> 是逻辑右移操作符. C. >> 是算术右移操作符 D. >>> 是逻辑右移操作符 答:AD

43. 下面赋值语句合法的是 (第三章) A. float a = 2.0 B. double b = 2.0 C. int c = 2 D. long d = 2 答:BCD

44.已知如下代码: (第三章) boolean m = false; if ( m == true)

System.out.println(\ else

System.out.println(\ 执行结果是 A. False B. True C. None

D.运行时出错 答: B

45. 已知如下代码: (第三章) public class Test {

public static void main(String arg[])

{

int i = 5; do {

System.out.println(i); } while (--i>5)

System.out.println(\ } }

执行后的输出是 A. 5 B. 4 C. 6

D. finished E.无输出结果 答:AD

46.下面代码执行后的输出是(第三章) outer: for(int i=0;i<3; i++) inner: for(int j=0;j<2;j++) {

if(j==1) continue outer;

System.out.println(j+ \ }

A. 0 and 0 B. 0 and 1 C. 0 and 2 D. 1 and 0 E. 1 and 1 F. 1 and 2 G. 2 and 0 H. 2 and 1 I. 2 and 2 答: ABC

47. 已知如下代码: (第三章) switch (m) {

case 0: System.out.println(\ case 1: System.out.println(\ case 2: System.out.println(\

case 3: System.out.println(\ default: System.out.println(\ }

当m的值为多少时输出\

A. 0 B. 1 C. 2 D. 3 E. 4 F. None 答:ABC

48.下面语句段的输出结果是什么? (第三章) int i = 9; switch (i) { default:

System.out.println(\ case 0:

System.out.println(\ break; case 1:

System.out.println(\ case 2:

System.out.println(\ A. default

B. default, zero

C. default语句定义错误 D. 无输出显示 答案B

49. 下述程序的输出正确的是(第三章) public class Outer{

public static void main(String args[]){ for(int i=0; i<3; i++) for(int j=0;j<3;j++){ if(j>1) break;

System.out.println(j+\} } }

A. 0 and 0 B. 0 and 1 C. 0 and 2 D. 0 and 3 E. 2 and 2 F. 2 and 1 G. 2 and 0 答案ABC

50.假设a是int 类型的变量,并初始化为1,则下列不合法的条件语句(第三章) A. if(a){}

B. if(a<<=3){} C. if(a=2){} D. if(true){} 答案 ABC

Java语言程序设计(2)

1.下列说法中正确的是(第三章)

A.switch语句功能可以由if-else if语句来实现

B.若用于比较的数据类型为double,则不可以用switch语句实现 C.if-else if语句的执行效率总是比switch语句高

D. case子句中可以有多个语句,并且不需要用大括号{}括起来 答案 ABD

2.下列循环执行的次数是(第三章) int y=2, x=4; while(--x!=x/y){} A. 1次 B. 2次 C. 3次 D. 0次 答案 C

3.下列程序执行后,输出的结果是(第三章) public class C34{

public static void main(String[ ] args){ boolean m=true; if(m==false)

System.out.println(“flase”); else if(m==true)

System.out.println(“true”); else

System.out.println(“error”); } }

A. true B. false C. error D. 编译出错 答案 A