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