OCJP考试题库

所需积分/C币:11 2018-06-20 11:34:36 8.87MB PDF
13
收藏 收藏
举报

1z0-851_formatted OCJP 31题 供大家学习参考交流 虽然在国内IT业内各种考证被许多牛人不齿,用人单位也往往不做硬性要求,但是自从SUN公司被ORACLE收购之后,JAVA的认证考试的难度是有目共睹的,目前传出的消息OCJP的一次通过率只有10%左右,相当恐怖,不过这个数字恐怕在未来一段时间内会有大幅度上升。国内JAVA考试还未从过去的背考经时代完全醒过味来。OCJP的无考经时代是的众多考生铩羽而回。
12. private N min, max 13. public n getHin( return min; 1 14. public n getMax( return max; 1 15. public void add(n added)i 16. if (min== null l added. doublevalue(< min. doublevalueO) 17. min added 18. if (max ==null l added. doublevalue(> max. doublevalue() 19. max = added 20.} 21.} Which two, inserted at line 11, will allow the code to compile?( choose two A. public class MinMax<?> t B. public class Min Max<? extends Number> C. public class MinMax<n extends object> t D. public class MinMax<N extends Number> i E. public class MinMax<? extends Object> i public class MinMax<N extends Integer> Answer: DF Section: (none) Explanation/Reference Explanation qUESTION 4 Given 2. import java. util 13. public class Explorer2 14. public static void main(String[ args)I 15. Tree<Integer> s= new Tree Set<Integer>o 16. Tree Set<Integer> subs new Tree Set<Integer>0 17. for(int i=606;i<613:++ 18.f(%2==0)sadd(); 19. subs=(Tree Set)s subSet(608, true, 611, true) 20.sadd(629); System. out. printIn(s++ subs); 22.} 23 What is the result? A. Compilation fails. B. An exception is thrown at runtime C.[608,610,612.629][608,610] D.[608,610,612,629]1608,610,629 E.[606,608,610,612,629]608,610] F.[606,608,610,612,629][608,610,629] Answer: E Section:(none) Explanation/Reference Explanation QUESTION 5 Given public class Score implements Comparable<Score>t 2.private int wins, losses: 3. public Score(int w, int I)i wins=W; losses=1; 1 4. public int getWinsoi return wins; J 5. public int getLosses(i return losses: 1 6. public String to String i 7 return "< wins +"" losses +"> 8.} 9./ insert code here 10.} Which method will complete this class? A. public int compare Toobject o)/more code here*/s B. public int compare To( Score other /"more code here/g C. public int compare(Score s1, Score s2) /more code here"/ D. public int compare(object o1, Object o2X/more code here*/ Answer: B Section:(none) Explanation/Reference Explanation QUESTION 6 Given 11. public class Person i 12. private name 13. public Person(String name) 14. this. name name 15.} 16. public int hash Code( i 17. return 420 18.} 19.} Which statement is true A. The time to find the value from HashMap with a Person key depends on the size of the map B. Deleting a Person key from a HashMap will delete all map entries for all keys of type Person C. Inserting a second Person object into a Hash Set will cause the first Person object to be removed as a duplicate D. The time to determine whether a Person object is contained in a Hash Set is constant and does not depend on the size of the map Answer:A Section: (none) Explanation/Reference: Explanation QUESTION 7 Given 5. import java. util. 6. public class Sortof 7. public static void main(String[] args)( 8. Array<Integer> a= new Array<Integer>o 9. a.add(1): a add(5): a add(3) 11. Collections. sort(a) 12.aadd(2); 13. Collections. reverse(a) 14. System. out. printIn (a); 15.} 16.} What is the result? A.[1,2,3,5] B.[2,1,3,5 C.[2,5,3,1 D.[5,3,2, E.[1,3,5,2] F. Compilation fails G. An exception is thrown at runtime Answer: C Section:(none) Explanation/Reference Explanation QUESTIoN 8 Given 11. public interface Status i 12. insert code here x/int MY ValUe=10 13.Which three are valid on line 12? hoose three A. final B. static C. native D. public E. private F abstract G. protected Answer: ABD Section: (none) Explanation/Reference Explanation QUESTION 9 Given 5. class Atom 6. Atom( System. out. print(atom );1 7.} 8. class Rock extends Atom i 9. Rock( String type)I System. out print(type); 1 10.} 11. public class Mountain extends Rock 12. Mountain t 13. super(granite"); 14. new Rock ( granite "); 15. 16. public static void main(String[ a)[ new Mountain (: 1 17 What is the result? A. Compilation fails B. atom granite C. granite granite D. atom granite granite E. An exception is thrown at runtime F. atom granite atom granite Answer: F Section:(none) Explanation/Reference Explanation QUESTION 10 Click the Exhibit button. Which three statements are true?(Choose three Exhibit 10 interface Foo 11 int bar() 12.} 13 14. public class Beta t 15 16 class a inplements Foo i 17 public int bar()t return 1: 18.} 19 20. public int fubar( Foo foo )i return foo. bar( 21 public void testFoo( t 23 4 class A implements Foo t public int bar()i return 2: 3 26 27 28 System. out. println( fubar( new A())): 29 30 public static void main( String[] argv )i 32 new Beta(. testFoo(: 33 34.} Close Tile Commen Hel A. Compilation fails B. The code compiles and the output is 2. C. If lines 16, 17 and 18 were removed, compilation would fail D. If lines 24, 25 and 26 were removed, compilation would fail E. If lines 16, 17 and 18 were removed the code would compile and the output would be 2 If lines 24, 25 and 26 were removed the code would compile and the output would be 1 Answer: BEeF Section:(none) Explanation/Reference Explanation QUESTION 11 Given 10. class Line i 11. public class Point i public int x, y: 1 12. public Point getPoint(i return new Point( 13.} 14. class Triangle 15. public Triangle(i 16/insert code here 17.} 18.} Which code, inserted at line 16, correctly retrieves a local instance of a Point object? A. Point p= Line. getPoint( B. Line Point p=Line. getPointo C. Point p=(new Line(). getPoint( D. Line Point p =(new Line(). getPointo Answer: D Section: (none Explanation/Reference Explanation: QUESTION 12 Given: 11. class Alpha i 12. public void fooi System.out. print("Afoo); y 13 14. public class Beta extends Alpha i 15. public void foooi System out. print("Bfoo); 1 16. public static void main(Stringl args)i 17. Alpha a= new Beta 18. Beta b=(Beta)a 19.aoo() 20.bo0(); 21.} 22 What is the result? A. Afoo afoo B. Foo bfoo C. Bfoo foo d. Foo bfoo E. Compilation fails F. An exception is thrown at runtime Answer D Section: (none) Explanation/Reference Explanation QUESTION 13 Click the exhibit button which statement is true about the classes and interfaces in the exhibit? Exhibit 口x 1. public interface a i 2. public void doSomething (String thing 3.} 1. public class AImpl implements a 2. public vo id doSomething(String msg)t 3 1. public class b t public A doit( i 3 / more code here 4.} 5 public String execute()[ / ore code here 8 912345678 9.} 1. public class c extends b f 2. public AImpl doit()[ more code here public Object execute(f more code here 9.} Close dle Comment A. Compilation will succeed for all classes and interfaces B. Compilation of class c will fail because of an error in line 2 C. Compilation of class C will fail because of an error in line 6 D. Compilation of class almpl will fail because of an error in line 2. Answer: C Section: (none) Explanation/Reference Explanation QUESTION 14 Which two code fragments correctly create and initialize a static array of int elements?(Choose two A. static final int[ a=( 100, 200; B. static final int[ a static f a=new int[2]; a[0]=100; a[1]=200: 1 C. static final intl a= new int[2] 100, 200] D. static final int[ a; static void init(i a= new int(3]; a[0]=100; a[1]=200; 1 Answer: AB Section:(none Explanation/Reference: Explanation

...展开详情
试读 127P OCJP考试题库
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
  • 分享精英

关注 私信
上传资源赚钱or赚积分
最新推荐
OCJP考试题库 11积分/C币 立即下载
1/127
OCJP考试题库第1页
OCJP考试题库第2页
OCJP考试题库第3页
OCJP考试题库第4页
OCJP考试题库第5页
OCJP考试题库第6页
OCJP考试题库第7页
OCJP考试题库第8页
OCJP考试题库第9页
OCJP考试题库第10页
OCJP考试题库第11页
OCJP考试题库第12页
OCJP考试题库第13页
OCJP考试题库第14页
OCJP考试题库第15页
OCJP考试题库第16页
OCJP考试题库第17页
OCJP考试题库第18页
OCJP考试题库第19页
OCJP考试题库第20页

试读结束, 可继续阅读

11积分/C币 立即下载 >