)92-147/147的文章 name=description>


SCJP考试题310-025(第二套<4>)92-147/147
来源:优易学  2011-9-22 20:30:08   【优易学:中国教育考试门户网】   资料下载   IT书店

QUESTION NO 131
Exhibit:
1. public class SwitchTest {
2. public static void main (String []args) {
3. System.out.PrintIn(“value =” +switchIt(4));
4. }
5. public static int switchIt(int x) {
6. int j = 1;
7. switch (x) {
8. case 1: j++;
9. case 2: j++;
10. case 3: j++;
11. case 4: j++;
12. case 5: j++;
13. default:j++;
14. }
15. return j + x;
16. }
17. }
What is the output from line 3?
A. Value = 3
B. Value = 4
C. Value = 5
D. Value = 6
E. Value = 7
F. Value = 8
Answer: F
QUESTION NO 132
Which four types of objects can be thrown using the throw statement? (Choose Four)
A. Error
B. Event
C. Object
D. Exception
E. Throwable
F. RuntimeException
Answer: A, D, E, F
QUESTION NO 133
Given:
1. public class ForBar {
2. public static void main(String []args) {
3. int i = 0, j = 5;
4. tp: for (;;) {
5. i ++;
6. for(;;)
7. if(i > --j) break tp;
8. }
9. system.out.printIn(“i = ” + i + “, j = “+ j);
10. }
11. }
What is the result?
A. The program runs and prints “i=1, j=0”
B. The program runs and prints “i=1, j=4”
C. The program runs and prints “i=3, j=4”
D. The program runs and prints “i=3, j=0”
E. An error at line 4 causes compilation to fail.
F. An error at line 7 causes compilation to fail.
Answer: A
QUESTION NO 134
Which two can directly cause a thread to stop executing? (Choose Two)
A. Exiting from a synchronized block.
B. Calling the wait method on an object.
C. Calling the notify method on an object.
D. Calling the notifyAll method on an object.
E. Calling the setPriority method on a thread object.
Answer: B, E
QUESTION NO 135
Given:
1. public class Foo implements Runnable (
2. public void run (Thread t) {
3. system.out.printIn(“Running.”);
4. }
5. public static void main (String[] args) {
6. new thread (new Foo()).start();
7. )
8. )
What is the result?
A. An exception is thrown.
B. The program exists without printing anything.
C. An error at line 1 causes compilation to fail.
D. An error at line 6 causes the compilation to fail.
E. “Running” is printed and the program exits.
Answer: C
QUESTION NO 136
Which constructs a DataOutputStream?
A. New dataInputStream(“in.txt”);
B. New dataInputStream(new file(“in.txt”));
C. New dataInputStream(new writer(“in.txt”));
D. New dataInputStream(new FileWriter(“in.txt”));
E. New dataInputStream(new InputStream(“in.txt”));
F. New dataInputStream(new FileInputStream(“in.txt”));
Answer: F
QUESTION NO 137
Which can be used to decode charS for output?
A. Java.io.InputStream.
B. Java.io.EncodedReader.
C. Java.io.InputStreamReader.
D. Java.io.InputStreamWriter.
E. Java.io.BufferedInputStream.
Answer: C
QUESTION NO 138
Given:
1. public class Test {
2. public static void main (String [] args) {
3. string foo = “blue”;
4. string bar = foo;
5. foo = “green”;
6. System.out.printIn(bar);
7. }
8. }
What is the result?
A. An exception is thrown.
B. The code will not compile.
C. The program prints “null”
D. The program prints “blue”
E. The program prints “green”
Answer: D
QUESTION NO 139
Which code determines the int value foo closest to a double value bar?
A. Int foo = (int) Math.max(bar);
B. Int foo = (int) Math.min(bar);
C. Int foo = (int) Math.abs(bar);
D. Int foo = (int) Math.ceil(bar);
E. Int foo = (int) Math.floor(bar);
F. Int foo = (int) Math.round(bar);
Answer: F

上一页  [1] [2] [3] [4] [5] [6] [7] [8] 下一页

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训