SCJP考试题310-025(8)

2019-05-24 21:45

F. 16>>>2 Answer: D, F

QUESTION NO: 97 Exhibit:

1. public class X {

2. public static void main (String[]args) { 3. int [] a = new int [1] 4. modify(a);

5. System.out.printIn(a[0]); 6. } 7.

8. public static void modify (int[] a) { 9. a[0] ++; 10. } 11. }

What is the result?

A. The program runs and prints “0” B. The program runs and prints “1”

C. The program runs but aborts with an exception.

D. An error “possible undefined variable” at line 4 causes compilation to fail. E. An error “possible undefined variable” at line 9 causes compilation to fail. Answer: B

QUESTION NO: 98 Given:

13. public class Foo {

14. public static void main (String [] args) { 15. StringBuffer a = new StringBuffer (“A”); 16. StringBuffer b = new StringBuffer (“B”); 17. operate (a,b);

18. system.out.printIn{a + “,” +b}; 19. )

20. static void operate (StringBuffer x, StringBuffer y) { 21. y.append {x}; 22. y = x; 23. ) 24. }

What is the result?

A. The code compiles and prints “A,B”. B. The code compiles and prints “A, BA”. C. The code compiles and prints “AB, B”. D. The code compiles and prints “AB, AB”. E. The code compiles and prints “BA, BA”.

F. The code does not compile because “+” cannot be overloaded for stringBuffer. Answer: B

QUESTION NO: 99 Given:

1. public class X {

2. public static void main (String[] args) { 3. byte b = 127; 4. byte c = 126; 5. byte d = b + c; 6. } 7. }

Which statement is true?

A. Compilation succeeds and d takes the value 253. B. Line 5 contains an error that prevents compilation. C. Line 5 throws an exception indicating “Out of range” D. Line 3 and 4 contain error that prevent compilation. E. The compilation succeeds and d takes the value of 1. Answer: B

QUESTION NO: 100 Given:

1. public class WhileFoo {

2. public static void main (String []args) { 3. int x= 1, y = 6; 4. while (y--) {x--;}

5. system.out.printIn(“x=” + x “y =” + y); 6. } 7. }

What is the result?

A. The output is x = 6 y = 0 B. The output is x = 7 y = 0 C. The output is x = 6 y = -1 D. The output is x = 7 y = -1 E. Compilation will fail. Answer: E

QUESTION NO: 101 Which statement is true?

A. The Error class is a untimeException. B. No exceptions are subclasses of Error.

C. Any statement that may throw an Error must be enclosed in a try block. D. Any statement that may throw an Exception must be enclosed in a try block. E. Any statement that may thro a runtimeException must be enclosed in a try block. Answer: D

QUESTION NO: 102 Exhibit:

1. int I=1, j=0 2.

3. switch(i) { 4. case 2: 5. j+=6; 6.

7. case 4: 8. j+=1; 9.

10. default: 11. j +=2; 12.

13. case 0: 14. j +=4; 15. } 16.

What is the value of j at line 16? A. 0 B. 1 C. 2 D. 4 E. 6

Answer: AE

QUESTION NO: 103 Given:

1. switch (i) { 2. default:

3. System.out.printIn(“Hello”); 4. )

What is the acceptable type for the variable i? A. Byte B. Long C. Float D. Double E. Object F. A and B G. C and D Answer: A

QUESTION NO: 104

You need to store elements in a collection that guarantees that no duplicates are stored. Which two interfaces provide that capability? (Choose Two) A. Java.util.Map B. Java.util.Set C. Java.util.List

D. Java.util.StoredSet E. Java.util.StoredMap

F. Java.util.Collection Answer: B, D

QUESTION NO: 105

Which statement is true for the class java.util.ArrayList? A. The elements in the collection are ordered. B. The collection is guaranteed to be immutable.

C. The elements in the collection are guaranteed to be unique. D. The elements in the collection are accessed using a unique key. E. The elements in the collections are guaranteed to be synchronized. Answer: A

QUESTION NO: 106 Exhibit:

1. public class X implements Runnable( 2. private int x; 3. private int y; 4.

5. public static void main(String[]args) 6. X that = new X();

7. (new Thread(that)).start(); 8. (new Thread(that)).start(); 9. ) 10.

11. public void run() ( 12. for (;;) ( 13. x++; 14. y++;

15. System.out.printIn(“x=” + x + “, y = ” + y); 16. ) 17. ) 18. )

What is the result?

A. Errors at lines 7 and 8 cause compilation to fail.

B. The program prints pairs of values for x and y that might not always be the same on the same line

(for example, “x=2, y=1”).

C. The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears twice (for example, “x=1, y=1” followed by “x=1, y=1”).

D. The program prints pairs of values for x and y that are always the same on the same line (for example, “x=1, y=1”. In addition, each value appears only for once (for example, “x=1, y=1” followed by “x=2, y=2”). Answer: D

QUESTION NO: 107 Given:

1. public class SyncTest { 2. private int x; 3. private int y;

4. public synchronized void setX (int i) (x=1;) 5. public synchronized void setY (int i) (y=1;)

6. public synchronized void setXY(int 1)(set X(i); setY(i);) 7. public synchronized Boolean check() (return x !=y;) 8. )

Under which conditions will check () return true when called from a different class? A. Check() can never return true.

B. Check() can return true when setXY is called by multiple threads.

C. Check() can return true when multiple threads call setX and setY separately.

D. Check() can only return true if SyncTest is changed to allow x and y to be set separately. Answer: A

QUESTION NO: 108

Which is a method of the MouseMotionListener interface? A. Public void mouseDragged(MouseEvent) B. Public boolean mouseDragged(MouseEvent) C. Public void mouseDragged(MouseMotionEvent) D. Public boolean MouseDragged(MouseMotionEvent) E. Public boolean mouseDragged(MouseMotionEvent) Answer: A

QUESTION NO: 109 Given:

1. String foo = “base”; 2. foo.substring(0,3); 3. foo.concat(“ket”); 4. foo += “ball”; 5.

Type the value of foo at line 8. Answer: BASEBALL QUESTION NO 110 Given:

1. public class Test {

2. public static void leftshift(int i, int j) { 3. i<<=j; 4. }

5. public static void main(String args[]) { 6. int i = 4, j = 2; 7. leftshift(i, j);

8. System.out.printIn(i); 9. } 10. }

What is the result?


SCJP考试题310-025(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:《数据库原理》作业习题册

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: