SCJP考试题310-025(4)

2019-05-24 21:45

Which statement is true for the class java.util.HashSet? 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: C

Question No 46 Given:

1. public class IfTest (

2. public static void main(string[]args) { 3. int x = 3; 4. int y = 1; 5. if (x = y)

6. system.out.printIn(“Not equal”); 7. else

8. system.out.printIn(“Equal”); 9. } 10. )

What is the result?

A. The output is “Equal” B. The output in “Not Equal”

C. An error at line 5 causes compilation to fall.

D. The program executes but does not print a message. Answer: C

Question No 47 Exhibit:

1. public class test (

2. public static void main(string args[]) { 3. int 1= 0; 4. while (i) { 5. if (i==4) { 6. break; 7. ) 8. ++i; 9. ) 10. 11. ) 12. )

What is the value of i at line 10? A. 0 B. 3 C. 4 D. 5

E. The code will not compile. Answer: E

Question No 48 Given:

3. int i= 1, j= 10 ; 4. do (

5. if (i++> --j) continue; 6. ) while (i<5);

After execution, what are the values for I and j? A. i = 6 and j= 5 B. i = 5 and j= 5 C. i = 6 and j= 4 D. i = 5 and j= 6 E. i = 6 and j= 6 Answer: D Question No 49 Given:

1. switch (i) { 2. default: 310-025

Leading the way in IT testing and certification tools, www.testking.com - 27 -

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

What are the two acceptable types for the variable i? (Choose Two) A. Char B. Byte C. Float D. Double E. Object Answer: A, B Question No 50 Given:

1. public class foo {

2. public static void main (string[]args) 3. try {return;}

4. finally {system.out.printIn(“Finally”);} 5. } 6. )

What is the result?

A. The program runs and prints nothing. B. The program runs and prints “Finally”

C. The code compiles, but an exception is thrown at runtime. D. The code will not compile because the catch block is missing.

Answer: B

这是第2套题中的51-90题 310-025

Leading the way in IT testing and certification tools, www.testking.com Question No 51 Exhibit:

1. import java.io.IOException; 2. public class ExceptionTest(

3. public static void main (String[]args) 4. try (

5. methodA();

6. ) catch (IOException e) (

7. system.out.printIn(“Caught IOException”); 8. ) catch (Exception e) (

9. system.out.printIn(“Caught Exception”); 10. ) 11. )

12. public void methodA () { 13. throw new IOException (); 14. ) 15. )

What is the result?

A. The code will not compile. B. The output is caught exception. C. The output is caught IOException.

D. The program executes normally without printing a message. Answer: A

Question No 52 Exhibit:

1. public class test {

2. public static string output = “” 3.

4. public static void foo(int i) { 5. try {

6. if(i= =1) {

7. throw new Exception (); 8. }

9. output += “1”; 10. )

11. catch(Exception e) { 12. output += “2”; 13. return; 14. )

15. finally (

16. output += “3”; 17. )

18. output += “4”; 19. ) 20.

21. public static void main (string args[]) ( 22. foo(0); 23. foo(1); 24. 25. ) 26. )

What is the value of the variable output at line 24? Answer: 13423 Question No 53 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 2 causes the compilation to fail. E. “Running” is printed and the program exits. Answer: D Question No 54

Which statement is true?

A. If only one thread is blocked in the wait method of an object, and another thread executes the modify on that same object, then the first thread immediately resumes execution.

B. If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, it is still possible that the first thread might never resume execution. C. If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, then the first thread definitely resumes execution as a direct and sole consequence of the notify call.

D. If two threads are blocked in the wait method of one object, and another thread executes the notify

method on the same object, then the first thread that executed the wait call first definitely resumes execution as a direct and sole consequence of the notify call. Answer: B

Question No 55

Which two CANNOT directly cause a thread to stop executing? (Choose Two) A. Calling the yield method.

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 start method on another Thread object. Answer: C, D Question No 56

Which two can be used to create a new Thread? (Choose Two) A. Extend java.lang.Thread and override the run method. B. Extend java.lang.Runnable and override the start method. C. Implement java.lang.thread and implement the run method. D. Implement java.lang.Runnable and implement the run method. E. Implement java.lang.Thread and implement the start method. Answer: A, D Question No 54

Which statement is true?

A. If only one thread is blocked in the wait method of an object, and another thread executes the modify on that same object, then the first thread immediately resumes execution.

B. If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, it is still possible that the first thread might never resume execution. C. If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, then the first thread definitely resumes execution as a direct and sole consequence of the notify call.

D. If two threads are blocked in the wait method of one object, and another thread executes the notify

method on the same object, then the first thread that executed the wait call first definitely resumes execution as a direct and sole consequence of the notify call. Answer: B

Question No 55

Which two CANNOT directly cause a thread to stop executing? (Choose Two) A. Calling the yield method.

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 start method on another Thread object. Answer: C, D Question No 56

Which two can be used to create a new Thread? (Choose Two) A. Extend java.lang.Thread and override the run method. B. Extend java.lang.Runnable and override the start method. C. Implement java.lang.thread and implement the run method. D. Implement java.lang.Runnable and implement the run method.


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

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

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

马上注册会员

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