ImageVerifierCode 换一换
格式:DOC , 页数:41 ,大小:161.50KB ,
资源ID:1336856      下载积分:5000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-1336856.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(【计算机类职业资格】计算机Java认证-5及答案解析.doc)为本站会员(吴艺期)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

【计算机类职业资格】计算机Java认证-5及答案解析.doc

1、计算机 Java认证-5 及答案解析(总分:100.00,做题时间:90 分钟)一、不定项选择题(总题数:44,分数:100.00)1.Given: 3. class Department 4. Department getDeptName() return new Department(); 5. 6. class Accounting extends Department 7. Accounting getDeptName() return new Accounting(); 8. / insert code here 13. And the following four code fra

2、gments: . String getDeptName(int x) return “mktg“; . void getDeptName(Department d) ; . void getDeptName(long x) throws NullPointerException throw new NullPointerException(); . Department getDeptName() throws NullPointerException throw new NullPointerException(); return new Department(); Which are t

3、rue? (Choose all that apply.)(分数:1.50)A.If fragment is inserted at line 8, the code compiles.B.If fragment is inserted at line 8, the code compiles.C.If fragment is inserted at line 8, the code compiles.D.If fragment is inserted at line 8, the code compiles.E.If none of the fragments are inserted at

4、 line 8, the code compiles.2.Given: 2. import java.util.*; 3. interface Canine 4. class Dog implements Canine 5. public class Collie extends Dog 6. public static void main(String args) 7. ListDog d = new ArrayListDog(); 8. ListCollie c = new ArrayListCollie(); 9. d. add (new Collie(); 10. c. add (ne

5、w Collie(); 11. do1(d); do1(c); 12. do2(d); do2(c); 13. 14. static void dol (List? extends Dog d2) 15. d2.add(new Collie(); 16. System.out.print(d2.size(); 17. 18. static void do2(List? extends Canine c2) 19. Which are true? (Choose all that apply.)(分数:1.50)A.Compilation succeeds.B.Compilation fails

6、 due to an error on line 9.C.Compilation fails due to an error on line 14.D.Compilation fails due to an error on line 15.E.Compilation fails due to an error on line 16.F.Compilation fails due to an error on line 18.G.Compilation fails due to errors on lines 11 and 12.3.Given: 42. void go() 43. int c

7、ows = 0; 44. int twisters = 1,2,3; 45. for(int i = 0; i 4; i+) 46. switch(twistersi) 47. case 2: cows+; 48. case 1: cows += 10; 49. case 0: go(); 50. 51. System.out.println(cows); 52. What is the result?(分数:1.50)A.11B.21C.22D.Compilation fails.E.A StackOverflowError is thrown at runtime.F.An Arrayln

8、dexOutOfBoundsException is thrown at runtime.4.Given: 2. class Robot 3. interface Animal 4. class Feline implements Animal 5. public class BarnCat extends Feline 6. public static void main(String args) 7. Animal af = new Feline(); 8. Feline ff = new Feline(); 9. BarnCat b = new BarnCat(); 10. Robot

9、r = new Robot(); 11. if(af instanceof Animal) System.out.print(“1 “); 12. if(af instanceof BarnCat) System.out.print(“2 “); 13. if(b instanceof Animal) System.out.print(“3 “); 14. if(ff instanceof BarnCat) System.out.print (“4 “); 15. if(r instanceof Animal) System.out .print (“5 “); 16. 17. What is

10、 the result?(分数:1.50)A.1B.1 3C.1 2 3D.1 3 4E.1 2 3 4F.Compilation fails.G.An exception is thrown at runtime.5.Given: 2. public class Sunny extends Weather 3. public static void main(String args) 4. try 5. new Sunny() .do1(); 6. new Sunny() .do2(); 7. new Sunny() .do3(); 8. 9. catch(Throwable t) Syst

11、em.out.print(“exc “); 10. 11. class Weather 12. void do1() System.out.print(“do1 “); 13. private void do2() System.out.print(“do2 “); 14. protected void do3() System.out.print(“do3 “); 15. What is the result?(分数:1.50)A.do1 excB.do1 do2 excC.do1 do2 do3D.Compilation fails.E.An exception is thrown at

12、runtime.6.Given that FileNotFoundException extends IOException and given: 2. import java.io.*; 3. public class Changeup 4. public static void main(String args) throws IOException 5. new Changeup() .go(); 6. new Changeup() .go2(); 7. new Changeup() .go3(); 8. 9. void go() throw new IllegalArgumentExc

13、eption(); 10. 11. void go2() throws FileNotFoundException 12. 13. void go3() 14. try throw new Exception(); 15. catch (Throwable th) throw new NullPointerException(); 16. What is the result? (Choose all that apply.)(分数:1.50)A.An IOException is thrown at runtime.B.A NullPointerException is thrown at

14、runtime.C.An IllegalArgumentException is thrown at runtime.D.Compilation fails due to an error at line 4.E.Compilation fails due to an error at line 9.F.Compilation fails due to an error at line 11.G.Compilation fails due to an error at line 15.7.Which are true? (Choose all that apply.)(分数:1.50)A.If

15、 class A is-a class B, then class A cannot be considered well encapsulated.B.If class A has-a class B, then class A cannot be considered well encapsulated.C.If class A is-a class B, then the two classes are said to be cohesive.D.If class A has-a class B, then the two classes are said to be cohesive.

16、E.If class A is-a class B, it“s possible for them to still be loosely coupled.F.If class A has-a class B, it“s possible for them to still be loosely coupled.8.Given: 2. import java.util.*; 3. public class Volleyball 4. public static void main(String args) 5. TreeSetString s = new TreeSetString(); 6.

17、 s.add(“a“); s.add(“f“); s.add(“b“); 7. System.out.print(s + “ “); 8. Collections.reverse(s); 9. System.out.println(s); 10. What is the result?(分数:1.50)A.Compilation fails.B.a, b, f a, b, fC.a, b, f f, b, aD.a, f, b b, f, aE.a, b, f, followed by an exception.F.a, f, b, followed by an exception.9.Giv

18、en: 2. public class Boggy 3. final static int mine = 7; 4. final static Integer i = 57; 5. public static void main(String args) 6. int x : go(mine); 7. System.out.print(mine + “ “ + x + “ “); 8. x += mine; 9. Integer i2 = i; 10. i2 = go(i); 11. System.out.println(x + “ “ + i2); 12. i2 = new Integer(

19、60); 13. 14. static int go(int x) return +x; 15. What is the result?(分数:1.50)A.7 7 14 57B.7 8 14 57C.7 8 15 57D.7 8 15 58E.7 8 16 58F.Compilation fails.G.An exception is thrown at runtime.10.Given: 3. import java.io.*; 4. public class Kesey 5. public static void main(String args) throws Exception 6.

20、 File file = new File(“bigData.txt“); 7. FileWriter w = new FileWriter(file); 8. w.println(“lots o“ data“); 9. w.flush(); 10. w.close(); 11. What is the result? (Choose all that apply.)(分数:1.50)A.An empty file named “bigData.txt“ is created.B.Compilation fails due only to an error on line 5.C.Compil

21、ation fails due only to an error on line 6.D.Compilation fails due only to an error on line 7.E.Compilation fails due only to an error on line 8.F.Compilation fails due to errors on multiple lines.G.A file named “bigData.txt“ is created, containing one line of data.11.Given: 3. class Wanderer implem

22、ents Runnable 4. public void run() 5. for(int i = 0; i 2; i+) 6. System.out.print(Thread.currentThread() .getName() + “ “); 7. 8. public class Wander 9. public static void main(String args) 10. Wanderer w = new Wanderer(); 11. Thread t1 = new Thread(); 12. Thread t2 = new Thread(w); 13. Thread t3 =

23、new Thread(w, “fred“); 14. t1.start(); t2.start(); t3.start(); 15. Which are true? (Choose all that apply.)(分数:2.50)A.Compilation fails.B.No output is produced.C.The output could be Thread- 1 fred fred Thread- 1D.The output could be Thread-1 Thread-1 Thread-2 Thread-2E.The output could be Thread-1 f

24、red Thread-1 Thread-2 Thread-2 fredF.The output could be Thread-1 Thread-1 Thread-2 Thread-3 fred fred12.Given: 2. import java.util.*; 3. public class MyFriends 4. String name; 5. MyFriends(String s) name = s; 6. public static void main(String args) 7. SetMyFriends ms = new HashSetMyFriends(); 8. ms

25、.add(new MyFriends(“Bob“); 9. System.out.print(ms + “ “); 10. ms.add(new MyFriends(“Bob“); 11. System.out.print(ms + “ “); 12. ms.add(new MyFriends(“Eden“); 13. System.out.print(ms + “ “); 14. 15. public String toString() return name; 16. What is the most likely result?(分数:2.50)A.Compilation fails.B

26、.Bob Bob Eden, BobC.Bob Bob Eden, Bob, BobD.Bob, followed by an exception.E.Bob Bob, Bob Eden, Bob, Bob13.Given the proper imports, and given: 17. public void go() 18. NumberFormat nf, nf2; 19. Number n; 20. Locale la = NumberFormat.getAvailableLocales(); 21. for(int x=0; x 10; x+) 22. nf = NumberFo

27、rmat.getCurrencyInstance(lax); 23. System.out.println(nf.format(123.456f); 24. 25. nf2 = NumberFormat.getInstance(); 26. n = nf2.parse(“123.456f“); 27. System.out.println(n); 28. Given that line 20 is legal, which are true? (Choose all that apply.)(分数:2.50)A.Compilation fails.B.An exception is throw

28、n at runtime.C.The output could contain “123.46“D.The output could contain “123.456“E.The output could contain “$123.46“14.Given: 59. Integer i1 = 2001; / set 1 60. Integer i2 = 2001; 61. System.out.println(i1 = i2) + “ “ + i1.equals(i2); / output 1 62. Integer i3 = 21; / set 2 63. Integer i4 = new

29、Integer(21); 64. System.out.println(i3 = i4) + “ “ + i3.equals(i4); / output 2 65. Integer i5 = 21; / set 3 66. Integer i6 = 21; 67. System.out.println(i5 = i6) + “ “ + i5.equals(i6); / output 3 What is the result? (Choose all that apply.)(分数:2.50)A.Compilation fails.B.An exception is thrown at runt

30、ime.C.All three sets of output will be the same.D.The last two sets of output will be the same.E.The first two sets of output will be the same.F.The first and last sets of output will be the same.15.Given: 2. public class Skip 3. public static void main(String args) throws Exception 4. Thread t1 = n

31、ew Thread(new Jump(); 5. Thread t2 = new Thread(new Jump(); 6. t1.start(); t2.start(); 7. t1.join(500); 8. new Jump() .run(); 9. 10. class Jump implements Runnable 11. public void run() 12. for(int i = 0; i 5; i+) 13. try Thread.sleep(200); 14. catch (Exception e) System.out.print(“e “); 15. System.

32、out.print(Thread.currentThread() .getId() + “-“ + i+ “ “); 16. What is the result?(分数:2.50)A.Compilation fails.B.The main thread will run mostly before t1 runs.C.The main thread will run after t1, but together with t2.D.The main thread will run after t2, but together with t1.E.The main thread will r

33、un after both t1 and t2 are mostly done.F.The main thread“s execution will overlap with t1 and t2“s execution.16.Given: 1. import java.util.*; 2. public class Piles 3. public static void main (String args) 4. TreeMapString, String tm = new TreeMapString, String(); 5. TreeSetString ts = new TreeSetSt

34、ring(); 6. String k = “1“, “b“, “4“, “3“; 7. String v = “a“, “d“, “3“, “b“; 8. for(int i=0; i4; i+) 9. tm.put (ki, vi); 10. ts.add(vi); 11. 12. System.out.print(tm.values() + “ “); 13. Iterator it2 = ts.iterator(); 14. while(it2.hasNext() System.out.print(it2.next() + “-“); 15. Which of the followin

35、g could be a part of the output? (Choose two.) A. a, b, 3, d B. d, a, b, 3 C. 3, a, b, d D. a, b, d, 3 E. 1, 3, 4,b F. b, 1,3,4 G. 3-a-b-d- H. a-b-d-3- I. a-d-3-b- (分数:2.50)A.B.C.D.E.F.G.H.I.17.Given this code in a method: 5. String s = “dogs. with words.“; 6. / insert code here 7. for(String o: out

36、put) 8. System.out.print(o + “ “); Which of the following, inserted independently at line 6, will produce output that contains the String “dogs“? (Choose all that apply.)(分数:2.50)A.String output = s.split(“s“);B.String output = s.split(“d“);C.String output = s.split(“/d“);D.String output = s.split(“

37、/s“);E.String output = s.split(“/w“);F.String output = s.split(“/.“);18.Given the design implied by this partially implemented class: 2. public class RobotDog 3. int size; 4. void bark() /* do barking */ 5. int getSize() return size; 6. size = 16; 7. int getNetworkPrinterID() 8. /* do lookup */ 9. r

38、eturn 37; 10. 11. voidprintRobotDogStuff(intprinterID) /*print RobotDog stuff*/ 12. Which are true? (Choose all that apply.)(分数:2.50)A.Compilation fails.B.To improve cohesion, the size variable should be declared private.C.To improve cohesion, the initialization block should be placed inside a const

39、ructor.D.To improve cohesion, printRobotDogStuff() should be moved to a different class.E.To improve cohesion, getNetworkPrinterlD0 should be moved to a different class.19.Given: 2. import java.util.*; 3. public class Foggy extends Murky 4. public static void main(String args) 5. final ListString s

40、= new ArrayListString(); 6. s.add(“a“); s.add(“f“); s.add(“a“); 7. new Foggy() .mutate(s); 8. System.out.println(s); 9. 10. ListString mutate (ListString s) 11. ListString ms = s; 12. ms.add (“c“); 13. return s; 14. 15. 16. class Murky 17. final void mutate(Set s) 18. What is the most likely result?

41、(分数:2.50)A.a,fB.a, f, aC.a, f, cD.a, f, a, cE.Compilation fails.F.An exception is thrown at runtime.20.Given: 1. import java.util.*; 2. enum Heroes GANDALF, HANS, ENDER 3. public class MyStuff 4. public static void main(String args) 5. ListString stuff = new ArrayListString(); 6. stuff.add(“Bob“); s

42、tuff.add(“Fred“); 7. new MyStuff().go(); 8. 9. Heroes myH = Heroes.ENDER; 10. void go() 11. for(Heroes h: Heroes.values() 12. if(h = myH) System.out.println(myH); 13. Which are true? (Choose all that apply.)(分数:2.50)A.Compilation fails.B.main() has-a ListC.MyStuffhas-a ListD.MyStuff has-a HeroesE.Th

43、e output is “ENDER“F.The output is “Heroes.ENDER“G.An exception is thrown at runtime.21.Given: 2. public class Pregnant extends Thread 3. int x = 0; 4. public static void main(String args) 5. Runnable r1 = new Pregnant(); 6. new Thread(r1) .start(); 7. new Thread(r1) .start(); 8. 9. public void run(

44、) 10. for(int j = 0; j 3; j+) 11. x = x + 1; 12. x = x + 10; 13. System.out.println(x + “ “); 14. x = x + 100; 15. If the code compiles, which value(s) could appear in the output? (Choose all that apply.)(分数:2.50)A.12B.22C.122D.233E.244F.566G.Compilation fails.22.Given: 2. public class Toolbox 3. st

45、atic Toolbox st; 4. public static void main(String args) 5. new Toolbox().go(); 6. / what“s eligible? 7. 8. void go() 9. MyInner in = new MyInner(); 10. Integer i3 = in.doInner(); 11. Toolbox t = new Toolbox(); 12. st = t; 13. System.out.println(i3); 14. 15. class MyInner 16. public Integer doInner(

46、) return new Integer(34); 17. 18. When the code reaches line 6, which are eligible for garbage collection? (Choose all that apply.)(分数:2.50)A.stB.inCi3D.The object created on line 5.E.The object created on line 9.F.The object created on line 10.G.The object created on line 11.23.Given: 2. class Ball

47、 3. static String s = “; 4. void doStuff() s += “bounce “; 5. 6. class Basketball extends Ball 7. void doStuff() s += “swish “; 8. 9. public class Golfball extends Ball 10. public static void main(String args) 11. Ball b = new Golfball(); 12. Basketball bb = (Basketball)b; 13. b.doStuff(); 14. bb.do

48、Stuff(); 15. System.out.println(s); 16. 17. void doStuff() s += “fore “; 18. What is the result?(分数:2.50)A.fore foreB.fore swishC.bounce swishD.bounce bounceE.Compilation fails.F.An exception is thrown at runtime.24.Given the following three files: 2. package apollo; 3. import apollo.modules.Lunar; 4. public class

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1