第 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
第 43题 The following code displays ___________. double temperature = 50; if (temperature >= 100)
System.out.println(\hot\else if (temperature <= 40) System.out.println(\cold\
System.out.println(\ 1、 too hot 2、 too cold 3、 just right
4、 too hot too cold just right 答案 3 第 44题 Analyze the following code: Code 1: boolean even
=
even; true;
if else
(number % 2 == 0) even = false; Code 2:
boolean even = (number % 2 == 0); 1、 Code 1 has compile errors. 2、 Code 2 has compile errors.
3、 Both Code 1 and Code 2 have compile errors.
4、 Both Code 1 and Code 2 are correct, but Code 2 is better. 答案 4 第 45题 The __________ method immediately terminates the program.
1、 System.terminate(0); 2、 System.halt(0);
3、 System.exit(0); 4、 System.stop(0); 答案 3 第 46题 What is the printout of the following switch statement? char ch = a ; switch case A :
System.out.print(ch); break; case b : case B :
(ch)
{ case a :