1.In programming,a loop is generally used to achieve__?
A. branching
B. succession
C. repetition
D. selection.
Correct Answer : C
2. Which of the following is the java loop construct typically used when the ramge is clear?
A. do-while-loop
B. switch-loop
C. for-loop
D. while-loop
Correct Answer : C
3. How many lines of output will be producted by the following code fragment?
for (int i = 0; i < 4; ++i){
for (int j = 1; j < 3; ++j){
System.out.println(i+j);
}
}
A. 8
B. 10
C. 6
D. 12
Correct Answer : A
4. 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;
}
System.out.println(count);
A. 4
B. 1
C. 6
D. 3
Correct Answer : D
5. How many bytes are required to represent a unicode character?
A. Two
B. Three
C. Four
D. One
Correct Answer : A
6. How many lines will be produced by the following code fragment?
for (int i = 0; i < 3; ++i) {
for(int j = 0; j < i; ++j) {
System.out.println(i+j);
}
}
A. 3
B. 5
C. 6
D. 4
Correct Answer : A
7. The term wrapper classes refers to__?
A. a collection of java classes that contain other java classes.
B. a collection of java classes that "wrap" java primitive types.
C. the java classes that contain themselves.
D. the java classes that contain at least two data fields.
Correct Answer : B
8. 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 8.
C. The output caused by the code will be 512.
D. The output caused by the code will be 5 1 2.
Correct Answer : C
9. Which of the following parts of an if-else-statement is optional?
A. the condition.
B. the parenthesis around the condition.
C. the else part
D. the if part.
Correct Answer : C
10. The primitive floating-point types available in java are __ and __?
A. real, float
B. single, real
C. float, double
D. real, double
Correct Answer : C
(部分题目来源于网络,如有侵权,请联系文章作者删除。)