测试题一
1.The term wrapper classes refers to
|
A. |
the Java classes that contain at least two data fields |
|
B. |
a collection of Java classes that contain other Java classes |
|
C. |
the Java classes that contain themselves |
|
D. |
a collection of Java classes that "wrap" Java primitive types |
所选答案: B.
a collection of Java classes that contain other Java classes
正确答案: D.
a collection of Java classes that "wrap" Java primitive types
2.Given the following code, what value will be output by the last statement?
StringTokenizer st = new StringTokenizer("this is,a,test of tokens", ",");
String s;
int count = 0;
while (st.hasMoreTokens())
{ s = st.nextToken();
++count;
}
stdOut.println(count);
|
A. |
4 |
||
|
B. |
1 |
||
|
C. |
3 |
||
|
D. |
6 |
||
所选答案: |
A. 4 |
|||
正确答案: |
C. 3 |
3.Which of the following statements is (are) true about the use of an asterisk (*) in a Java import statement?
1. It does not incur run-time overhead.
2. It can be used to import multiple packages with a single statement.
3. It can be used to import multiple classes with a single statement.
|
A. |
3 only |
|
B. |
1, 2, and 3 |
|
C. |
1 and 3 only |
|
D. |
1 only |
所选答案: A.
3 only
正确答案: C.
1 and 3 only
4.Consider the following Java program segment.
int x = 5; int y = 2; System.out.println(x + "1" + y);
Which of the following statements is true about the program segment?
|
A. |
The code will cause a compilation error. |
|
B. |
The output caused by the code will be 512. |
|
C. |
The output caused by the code will be 5 1 2. |
|
D. |
The output caused by the code will be 8. |
所选答案: B.
The output caused by the code will be 512.
正确答案: B.
The output caused by the code will be 512.
5.Which of the following patterns of characters opens a Javadoc comment block?
|
A. |
// |
|
B. |
**/ |
|
C. |
/** |
|
D. |
/* |
所选答案: D.
/*
正确答案: C.
/**
6.Classes from which of the following packages are implicitly imported into every Java program?
|
A. |
java.util |
|
B. |
java.lang |
|
C. |
java.awt |
|
D. |
java.io |
所选答案: B.
java.lang
正确答案: B.
java.lang
7.The name of a Java source file
|
A. |
must be the same as the class it defines, ignoring case |
||
|
B. |
has no restrictions |
||
|
C. |
must use the extension .class |
||
|
D. |
must be the same as the class it defines, respecting case |
||
所选答案: |
D. must be the same as the class it defines, respecting case |
|||
正确答案: |
D. must be the same as the class it defines, respecting case |
8.What will be output when the following Java program segment is executed?
int x = 5; int y = 2; System.out.println(x + y);
|
A. |
5+2 |
||
|
B. |
7 |
||
|
C. |
52 |
||
|
D. |
5 2 |
||
所选答案: |
B. 7 |
|||
正确答案: |
B. 7 |
9.What is the right way to handle abnormalities in input on Java?
|
A. |
By always specifying the throws clause in every method header where file I/O is performed |
||
|
B. |
By using the class FileFilter which gracefully filters out bad input data |
||
|
C. |
By handling these problems by providing exception handlers |
||
|
D. |
By writing while loops to guard against bad input |
||
所选答案: |
A. By always specifying the throws clause in every method header where file I/O is performed |
|||
正确答案: |
C. By handling these problems by providing exception handlers |
10.A tool that allows programmers to execute lines of a program one line at a time in order to help locate the source of a program's errors is known as a(n)
|
A. |
exception handler |
||
|
B. |
stack trace |
||
|
C. |
scope |
||
|
D. |
debugger |
||
所选答案: < |