A
注意事项:
请将题答案按编号顺序到答题卷上,答在试卷上无效。
一、单项选择题(1~20每小题1分,21~30每小题2分,共40分)
1.Which are keywords in Java?
A. Null                B. TRUE            C. sizeof                D. implements
2.Consider the following code:
Integer s = new Integer(9);
Integer t = new Integer(9);
Long u = new Long(9);
Which test would return true?
A. (s.equals(new Integer(9))                B. (s.equals(9))
C. (s==u)                            D. (s==t)
3.Which statement of assigning a long type variable to a hexadecimal value is correct?
A. long number = 345L;    B. long number = 0345;
C. long number = 0345L;      D. long number = 0x345L;
4.Which layout manager is used when the frame is resized the buttons's position in the Frame might be changed?
A. BorderLayout   B. FlowLayout  C. CardLayout  D. GridLayout
5.Which are not Java primitive types?
A. short  B. Boolean  C. byte  D. float
6.Given the following code:
  if (x>0) { System.out.println("first"); }
  else if (x>-3) { System.out.println("second"); }
  else { System.out.println("third"); }
Which range of x value would print the string "second"?
  A. x > 0  B. x > -3  C. x <= -3  D. x <= 0 & x > -3
7.Given the following code:
public class Person{
int arr[] = new int[10];
public static void main(String a[]) {
    System.out.println(arr[1]);
  }
}
Which statement is correct?
A. When compilation some error will occur.
B. It is correct when compilation but will cause error when running.
C. The output is zero.
D. The output is null.
8.Short answer:
resized
The decimal value of i is 13, the octal i value is:
A. 14                    B. 015                C. 0x14                D. 012
9.A public member vairable called MAX_LENGTH which is int type, the value of the variable remains constant value 100. Use a short statement to define the variable.
A. public int MAX_LENGTH=100;      B. final int MAX_LENGTH=100;
C. final public int MAX_LENGTH=100; D. public final int MAX_LENGTH=100.
10.Which correctly create an array of five empty Strings?
A. String a [] = {"", "", "", "", "", ""};            B. String a [5];        C. String [5] a;
D. String [] a = new String[5];  for (int i = 0; i < 5; a[i++] = null);
11.Given the following method body:
{if (sometest()) {
unsafe();
}else {
safe();
}
}
The method "unsafe" might throw an IOException (which is not a subclass of RunTimeException). Which correctly completes the method of declaration when added at line one?
A. public void methodName() throws Exception
B. public void methodname()
C. public void methodName() throw IOException
D. public IOException methodName()
12.What would be the result of attempting to compile and run the following piece of code?
public class Test {
static int x;
public static void main(String args[]){
System.out.println("Value is " + x);
}
}
A. The output "Value is 0" is printed.
B. An object of type NullPointerException is thrown.
C. A "possible reference before assignment" compiler error occurs.
D. An object of type ArrayIndexOutOfBoundsException is thrown.
13.What is the return-type of the methods that implement the MouseListener interface?
A. boolean            B. Boolean            C. void                D. Point
14.Select valid identifier of Java:
A. #pass            B. 3d_game            C. $charge            D. this
15.Given a TextField that is constructed like this:
TextField t = new TextField(30);
Which statement is true?
A. The displayed width is 30 columns.
B. The displayed string can use multiple fonts.
C. The displayed line will show exactly thirty characters.
D. The maximum number of characters in a line will be thirty.
16.Which declares an abstract method in an abstract Java class?
A. public abstract method();                    B. public abstract void method();
C. public void abstract Method(};            D. public abstract void method() {}
17.What happens when this method is called with an input of "Java rules"?
1. public String addOK(String S) {
2. S += " OK!";
3. return S;
4. }
Select one correct answer
A. The method will return "Java rules OK!".        B. A runtime exception will be thrown.
C. The method will return "OK!";            D. The method will return "Java rules".
18.Which of the following are Java keywords?
A. array        B. boolean        C. Integer        D. Long
19.Assume that val has been defined as an int for the code below.
if(val > 4){
System.out.println("Test A");
}else if(val > 9){
System.out.println("Test B");
}
else System.out.println("Test C");
Which values of val will result in "Test C" being printed: