SCJP题库.doc

上传人:11****ws 文档编号:2993607 上传时间:2019-05-16 格式:DOC 页数:133 大小:1.58MB
下载 相关 举报
SCJP题库.doc_第1页
第1页 / 共133页
SCJP题库.doc_第2页
第2页 / 共133页
SCJP题库.doc_第3页
第3页 / 共133页
SCJP题库.doc_第4页
第4页 / 共133页
SCJP题库.doc_第5页
第5页 / 共133页
点击查看更多>>
资源描述

1、Exam : 310-035Title : Sun Certified Programmer for Java 2Platform 1.4Ver : 06.20.06310-035QUESTION 1:Given:1. public class Test 2. public static void main(String args) 3. class Foo 4. public int i = 3;5. 6. Object o = (Object)new Foo();7. Foo foo = (Foo)o;8. System.out.println(“i = “ + foo.i);9. 10.

2、 What is the result?A. i = 3B. Compilation fails.C. A ClassCastException is thrown at line 6. D. A ClassCastException is thrown at line 7.Answer: AQUESTION 2:Which two cause a compiler error? (Choose two) A. float = new float(3);B. float f2 = new float;C. float f1 = new float3; D. float f3 = new flo

3、at3;E. float f5 = 1.0f, 2.0f, 2.0f ;F. float f4 = new float 1.0f. 2.0f. 3.0f;Answer: A, BThe F. statement is incorrect. The float numbers should be separated with commas and not dots.QUESTION 3:Given:11. int i =1,j =10;12. do 13. if(i+ -j) 14. continue;15. A - The Power of Knowing310-03516. while (i

4、 j) 14. break;15. 16. j-;17. while (+i 5);18. System.out.println(“i =“ +i+“ and j = “+j); What is the result?A. i = 6 and j = 5B. i = 5 and j = 5C. i = 6 and j = 4D. i = 5 and j = 6E. i = 6 and j = 6Answer: DQUESTION 9:Which statement is true?A. Assertions can be enabled or disabled on a class-by-cl

5、ass basis.B. Conditional compilation is used to allow tested classes to run at full speed.C. Assertions are appropriate for checking the validity of arguments in a method.D. The programmer can choose to execute a return statement or to throw an exception ifan assertion fails. Answer: AA - The Power

6、of Knowing310-035QUESTION 10:You want a class to have access to members of another class in the same package. Whichis the most restrictive access that accomplishes this objective?A. publicB. privateC. protectedD. transientE. default accessAnswer: EQUESTION 11:Given:11. int x = 3;12. int y = 1;13. if

7、 (x = y) 14. System.out.println(“x = “ + x);15. What is the result?A. x = 1B. x = 3C. Compilation fails.D. The code runs with no output.E. An exception is thrown at runtime. Answer: CQUESTION 12:Given:1. public class Test 2. public static void aMethod() throws Exception 3. try 4. throw new Exception

8、();5. finally 6. System.out.println(“finally“);7. 8. 9. public static void main(String args) 10. try 11. aMethod();A - The Power of Knowing310-03512. catch (Exception e) 13. System.out.println(“exception“);14. 15. System.out.println(“finished“);16. 17. What is the result?A. finallyB. exception finis

9、hedC. finally exception finishedD. Compilation fails. Answer: CQUESTION 13:Given:1. public interface Foo 2. int k = 4;3. Which three are equivalent to line 2? (Choose three)A. final int k = 4;B. public int k = 4; C. static int k=4;D abstract int;E. volatile int k = 4; F.protected int k=4;Answer: A,

10、B, CQUESTION 14:Given:1. package test1;2. public class Test1 3. static int x = 42;4. 1. package test2;2. public class Test2 extends test1.Test1 3. public static void main(String args) 4. System.out.println(“x = “ + x);A - The Power of Knowing310-0355. 6. What is the result?A. x = 0B. x = 42C. Compil

11、ation fails because of an error in line 2 of class Test2. D. Compilation fails because of an error in line 3 of class Test1. E. Compilation fails because of an error in line 4 of class Test2.Answer: CQUESTION 15:Given:1. class A 2. protected int method1(int a, int b) return 0; 3. Which two are valid

12、 in a class that extends class A? (Choose two)A. public int method1(int a, int b) return 0; B. private int method1(int a, int b) return 0; C. private int method1(int a, long b) return 0; D. public short method1(int a, int b) return 0: E. static protected int method1(int a, int b) return 0; Answer: A

13、, CQUESTION 16:Given:1. public class Delta 2. static boolean foo(char c) 3. System.out.print(c);4. return true;5. 6. public static void main( String argv ) 7. int i =0;8. for ( foo(A); foo(B) foo(C)9. i+ ;10. foo(D);12. 13. 14. What is the result?A - The Power of Knowing310-035A. ABDCBDCBB. ABCDABCD

14、C. Compilation fails.D. An exception is thrown at runtime. Answer: AQUESTION 17:Given:1. public class Test2. public static void main( String argv )3. / insert statement here4. 5. Which statement, inserted at line 3, produces the following output? Exception in thread “main“ java.lang.AssertionError:

15、trueat Test.main(Test.java:3)A. assert true; B. assert false;C. assert false : true;D. assert false = true; E. assert false: false;Answer: CQUESTION 18:Given:1. public class ArrayTest 2. public static void main(String args) 3. float fl, f2;4. fl = new float10;5. f2 = f1;6. System.out.println(“f20= “ + f20);7. 8. What is the result?A. It prints f20 = 0.0.B. It prints f20 = NaN.C. An error at line 5 causes compile to fail. D. An error at line 6 causes compile to fail.E. An error at line 6 causes an expectation at runtime.A - The Power of Knowing

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 实用文档资料库 > 策划方案

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。