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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

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

1、计算机 Java 认证-1 及答案解析(总分:100.00,做题时间:90 分钟)一、不定项选择题(总题数:44,分数:100.00)1.Given: 2. public class Bunnies 3. static int count=0; 4. Bunnies() 5. while (count10) new Bunnies (+count); 6. 7. Bunnies (int x) super(); 8. public static void main (String args) 9. new Bunnies(); 10. new Bunnies (count); 11. Syst

2、em. out. println (count+); 12. 13. What is the result?(分数:1.50)A.9B.10C.11D.12E.Compilation fails.F.An exception is thrown at runtime.2.Given: 2. public class Jail 3. private int x=4; 4. public static void main (String args) 5. protected int x=6; 6. new Jail() .new Cell() .slam(); 7. 8. class Cell 9

3、. void slam() System.out.println (“throw away key“ + x); 10. 11. Which are true? (Choose all that apply.)(分数:1.50)A.Compilation succeeds.B.The output is “throw away key 4“.C.The output is “throw away key 6“.D.Compilation fails due to an error on line 5.E.Compilation fails due to an error on line 6.F

4、.Compilation fails due to an error on line 9.3.Given: 2. public class Fabric extends Thread 3. public static void main (String args) 4. Thread t=new Thread (new Fabric(); 5. Thread t2=new Thread (new Fabric(); 6. t.start(); 7. t2.start(); 8. 9. public static void run() 10. for(int i=0; i2; i+) 11. S

5、ystem.out.print (Thread.currentThread() .getName() +“ “); 12. 13. Which are true? (Choose all that apply.)(分数:1.50)A.Compilation fails.B.No output is produced.C.The output could be Thread-1 Thread-3 Thread-1 Thread-2D.The output could be Thread-1 Thread-3 Thread-1 Thread-3E.The output could be Threa

6、d-1 Thread-1 Thread-2 Thread-2F.The output could be Thread-1 Thread-3 Thread-3 Thread-1G.The output could be Thread-1 Thread-3 Thread-1 Thread-14.Given: 2. class Feline 3. public class BarnCat2 extends Feline 4. public static void main (String args) 5. Feline ff=new Feline(); 6. BarnCat2 b=new BarnC

7、at2 (); 7. / insert code here 8. 9. Which, inserted independently at line 7, compile? (Choose all that apply.)(分数:1.50)A.if(b instanceof ff) System.out.print(“1 “);B.if(b.instanceof(ff) System.out.print(“2 “);C.if(b instanceofFeline) System.out.print(“3 “);D.if(b instanceOf Feline) System.out.print(

8、“4 “);E.if(b.instanceof(Feline) System.out.print(“5 “);5.Given: 2. public class Choosy 3. public static void main (String args) 4. String result=“ “; 5. int x=7, y=8; 6. if(x=3) result += “i“; 7. else if (x9) result += “2“; 8. else if (y9) result += “3“; 9. else if (x=7) result += “4“; 10. else resu

9、lt += “5“; 11. System.out.println (result); 12. 13. What is the result? (Choose all that apply.)(分数:1.50)A.3B.34C.35D.345E.Compilation fails due to an error on line 5.F.Compilation fails due to errors on lines 8 and 9.G.Compilation fails due to errors on lines 7, 8, and 96.Given: 1. public class Twi

10、ne 2. public static void main (String args) 3. String s=“; 4. StringBuffer sb1=new StringBuffer(“hi“); 5. StringBuffer sb2=new StringBuffer(“hi“); 6. StringBuffer sb3=new StringBuffer(sb2); 7. StringBuffer sb4=sb3; 8. if(sb1.equals(sb2) s += “1 “; 9. if(sb2.equals(sb3) s += “2 “; 10. if(sb3.equals(s

11、b4) s += “3 “; 11. String s2=“hi“; 12. String s3=“hi“; 13. String s4=s3; 14. if(s2.equals(s3) s += “4 “; 15. if(s3.equals(s4) s += “5 “; 16. System.out.println(s); 17. 18. What is the result?(分数:1.50)A.13B.15C.123D.145E.345F.1345G.12345H.Compilation fails.7.Which are true? (Choose all that apply.)(分

12、数:1.50)A.All classes of Exception extend Error.B.All classes of Error extend Exception.C.All Errors must be handled or declared.D.All classes of Exception extend Throwable.E.All Throwables must be handled or declared.F.All Exceptions must be handled or declared.G.RuntimeExceptions need never be hand

13、led or declared.8.Given: 2. import java.util.*; 3. public class Birthdays 4. public static void main(String args) 5. MapFriends, String hm=new HashMapFriends, String(); 6. hm.put(new Friends(“Charis“), “Summer 2009“); 7. hm.put(new Friends(“Draumur“), “Spring 2002“); 8. Friends f=new Friends(args0);

14、 9. System. out.println (hm.get(f); 10. 11. 12. class Friends 13. String name; 14. Friends(String n) name=n; 15. And the command line invocation: java Birthdays Draumur What is the result? A. null B. Draumur C. Spring 2002 D. Compilation fails. E. The output is unpredictable. F. An exception is thro

15、wn at runtime. G FriendsXXXX (where XXXX is a representation of a hashcode) (分数:1.50)A.B.C.D.E.F.G.9.Given: 2. import java.util.*; 3. class Cereal 4. public class Flakes extends Cereal 5. public static void main(String args) 6. ListFlakes c0=new ListFlakes(); 7. ListCereal c1=new ArrayListCereal();

16、8. ListCereal c2=new ArrayListFlakes(); 9. ListFlakes c3=new ArrayListCereal(); 10. ListObject c4=new ArrayListFlakes(); 11. ArrayListCereal c5=new ArrayListFlakes(); 12. 13. Which are true? (Choose all that apply.)(分数:1.50)A.Compilation succeeds.B.Compilation fails due to an error on line 6.C.Compi

17、lation fails due to an error on line 7.D.Compilation fails due to an error on line 8.E.Compilation fails due to an error on line 9.F.Compilation fails due to an error on line 10.G.Compilation fails due to an error on line 11.10.Given: 3. public class RediMix extends Concrete 4. RediMix() System.out.

18、println(“r “); 5. public static void main(String args) 6. new RediMix(); 7. 8. 9. class Concrete extends Sand 10. Concrete() System.out.print(“c “); 11. private Concrete(String s) 12. 13. abstract class Sand 14. Sand() System.out.print(“s “); 15. What is the result?(分数:1.50)ArB.c rC.r cD.s c rE.r c

19、sF.Compilation fails due to a single error in the code.G.Compilation fails due to multiple errors in the code.11.Which statement(s) are true? (Choose all that apply.)(分数:2.50)A.Coupling is the OO principle most closely associated with hiding a class“s implementation details.B.Coupling is the OO prin

20、ciple most closely associated with making sure classes know about other classes only through their APIs.C.Coupling is the OO principle most closely associated with making sure a class is designed with a single, well-focused purpose.D.Coupling is the OO principle most closely associated with allowing

21、 a single object to be seen as having many types.12.Given: 2. class Mosey implements Runnable 3. public void run() 4. for(int i=0; i1000; i+) 5. System.out.print(Thread.currentThread() .getId() +“-“+i+“ “); 6. 7. public class Stroll 8. public static void main(String args) throws Exception 9. Thread

22、t1=new Thread(new Mosey(); 10. /insert code here 11. 12. Which of the following code fragments, inserted independently at line 10, will probably run most (or all) of the main thread“s run() method invocation before running most of the t1 thread“s run() method invocation? (Choose all that apply.)(分数:

23、2.50)A.t1.setPriority(1);new Mosey().run();t1.start();B.t1.setPriority(9);new Mosey().run();t1.start();C.t1.setPriority(1);t1.start();new Mosey().run();D.t1.setPriority(8);t1.start();new Mosey().run();13.Given: 37. boolean b=false; 38. int i=7; 39. double d=1.23; 40. float f=4.56f; 41. 42. / insert

24、code here Which line(s) of code, inserted independently at line 42, will compile and run without exception? (Choose all that apply.)(分数:2.50)A.System.out.printf(“ %b“, b);B.System.out.printf(“ %i“, i);C.System.out.format(“ %d“, d);D.System.out.format(“ %d“, i);E.System.out.format(“ %f“, f);14.Given:

25、 1. import java.util.*; 2. public class MyPancake implements Pancake 3. public static void main(String args) 4. ListString x=new ArrayListString(); 5. x.add(“3“); x.add (“7“); x.add (“5“); 6. ListString y=new MyPancake() .doStuff(x); 7. y.add (“i“); 8. System.out.println (x); 9. 10. ListString doStu

26、ff(ListString z) 11. z.add(“9“); 12. return z; 13. 14. 15. interface Pancake 16. ListString doStuff(ListString s); 17. What is the most likely result?(分数:2.50)A.3,7,5B.3,7,5,9C.3,7,5,9,1D.Compilation fails.E.An exception is thrown at runtime.15.Given: 3. import java.util.*; 4. public class VLA2 impl

27、ements ComparatorVLA2 5. int dishSize; 6. public static void main(String args) 7. VLA2 va=new VLA2(40), new VLA2(200), new VLA2(60) ; 8. 9. Arrays.sort(va, va0); 10. int index=Arrays.binarySearch(va, new VLA2(40), va0); 11. System.out.print(index +“ “); 12. index=Arrays.binarySearch(va, new VLA2(80)

28、, va0); 13. System.out.print(index); 14. 15. public int compare(VLA2 a, VLA2 b) 16. return b.dishSize - a.dishSize; 17. 18. VLA2(int d) dishSize=d; 19. What is the result?(分数:2.50)A.0-2B.0-3C.2-1D.2-2E.Compilation fails.F.An exception is thrown at runtime.16.Given a directory structure: - baseDir -

29、testDir - subDir2 - Shackelton.txt and given the following code: 12. String name = “testDir“ + File.pathSeparator + “subDir2“ + File.pathSeparator + “Shackelton.txt“; 13. File f = new File (name); 14. System.out.println(“exists “ + f.exists(); Assuming the proper import statements and exception hand

30、ling, which statements must be true in order for the output to be “exists true“? (Choose three.)(分数:2.50)A.Line 12 is correct as it stands.B.Line 14 is correct as it stands.C.The program must be invoked from the baseDir directory.D.The program must be invoked from the testDir directory.E.Line 12 mus

31、t use File.separator instead of File.pathSeparator.F.Line 14 must use the method fileExists() instead of exists().17.Given: 1. import java.io.*; 2. import java.util.*; 3. import static java.lang. Short.*; 4. import static java.lang. Long.*; 5. public class MathBoy 6. public static void main(String a

32、rgs) 7. long x = 123456789; 8. short y = 22766; / maximum value of a short is 32767 9. System.out.printf(“%1$+10d %2$010d “, x, MAX VALUE - y); 10. System.out.println(new Date(); 11. 12. Which are true? (Choose all that apply.)(分数:2.50)A.Compilation fails.B.The output will include “+“C.The output wi

33、ll include “10001“D.The output will include “0000010001“E.The output will include today“s date.F.The output will include the number of milliseconds from January 1, 1970 until today.18.Given: 1. public class WeatherTest 2. static Weather w; 3. public static void main(String args) 4. System.out.print(

34、w.RAINY.count + “ “ + w. Sunny . count + “ “); 5. 6. 7. enum Weather 8. RAINY, Sunny; 9. int count = 0; 10. Weather() 11. System.out.print(“c “); 12. count+; 13. 14. What is the result?(分数:2.50)A.c1c1B.c1c2C.cc11D.cc12E.cc22F.Compilation fails.G.An exception is thrown at runtime.19.Given: 2. import

35、java.text.*; 3. public class Gazillion 4. public static void main(String args) throws Exception 5. String s = “123.456xyz“; 6. NumberFormat nf = NumberFormat.getInstance(); 7. System.out.println (nf.parse(s); 8. nf.setMaximumFractionDigits(2); 9. System.out.println (nf.format(s); 10. 11. Which are t

36、rue? (Choose all that apply.)(分数:2.50)A.Compilation fails.B.The output will contain “123.45 “C.The output will contain “123.456“D.The output will contain “123.456xyz“E.An exception will be thrown at runtime.20.Given that the current directory is bigApp, and the following directory structure: bigApp

37、|- classes |- com |- wickedlysmart |- BigAppMain.class And the code: package com.wickedlysmart; public class BigAppMain public static void main(String args) System. out.println(“big app“); Which will invoke BigAppMain? (Choose all that apply.)(分数:2.50)A.java classes/com.wickedlysmart.BigAppMainB.jav

38、a classes com/wickedlysmart/BigAppMainC.java .wickedlysmart.BigAppMainD.java -cp classes com.wickedlysmart.BigAppMainE.java -cp /classes com.wickedlysmart.BigAppMainF.java -cp .:classes com.wickedlysmart.BigAppMainG.java -cp classes/com/wickedlysmart com.wickedlysmart.BigAppMain21.Given: 2. class Ga

39、me 3. static String s = “-“; 4. String s2 = “s2“; 5. Game (String arg) s += arg; 6. 7. public class Go extends Game 8. Go() super(s2); 9. s += “i “; 10. public static void main(String args) 11. new Go (); 12. System.out.println(s); 13. 14. static s += “sb “; 15. What is the result?(分数:2.50)A.-sb i s

40、2B.-sb s2 iC.-s2 i sbD.-s2 sb iE.Compilation fails.F.An exception is thrown at runtime.22.Given: 2. public class Salmon extends Thread 3. public static long id; 4. public void run() 5. for(int i = 0; i4; i+) 6. / insert code here 7. new Thread(new Salmon() .start(); 8. throw new Error(); 9. 10. Syst

41、em.out.print (i +“ “); 11. 12. public static void main(String args) 13. Thread t1 = new Salmon(); 14. id = t1.getId(); 15. t1.start (); 16. And the two code fragments: . if(i = 2 4. public static void main(String args) 5. new Internet() .go(); 6. 7. void go() 8. int x = 7; 9. TCPIP ip = new TCPIP();

42、 10. class TCPIP 11. void doit() System.out.println(y + x); 12. 13. ip.doit (); 14. 15. What is the result? (Choose all that apply.)(分数:2.50)A.Compilation succeeds.B.Compilation fails due to an error on line 3.C.Compilation fails due to an error on line 8.D.Compilation fails due to an error on line

43、9.E.Compilation fails due to an error on line 10.F.Compilation fails due to accessing x on line 11.G.Compilation fails due to accessing y on line 11.24.Given: 4. public static void main(String args) 5. try 6. if(args.length = 0) throw new Exception(); 7. 8. catch (Exception e) 9. System.out .print (

44、“done “); 10. doStuff(); / assume this method compiles 11. 12. finally 13. System.out.println(“finally “); 14. 15. Which are possible outputs? (Choose all that apply.)(分数:2.50)A.“done “B.“finally“C.“done finally“D.Compilation fails.E.No output is produced.25.Given: 3. class A 4. class B extends A 5.

45、 class C extends B 6. public class CarpetV extends B 7. public X extends V Carpet? extends V method(Carpet? super X e) 8. / insert code here 9. Which, inserted independently at line 8, will compile? (Choose all that apply.)(分数:2.50)A.return new CarpetX();B.return new CarpetV();C.return new CarpetA()

46、;D.return new CarpetB();E.return new CarpetC();26.Given: 1. class One 2. int x = 0; 3. assert x = i; 4. 5. public class Two 6. public static void main(String args) 7. int y = 0; 8. assert y = 0; 9. if(args.length 0) 10. new One(); 11. 12. Which of the following will mn without error? (Choose all tha

47、t apply.)(分数:2.50)A.java TwoB.java Two xC.java -ea TwoD.java -ea Two xE.java -ea:One TwoF.java -ea:One Two xG.java -ea:Two Two x27.Given: 2. class SafeDeposit 3. private static SafeDeposit singleton; 4. public static SafeDeposit getInstance(int code) 5. if(singleton = null) 6. singleton = new SafeDe

48、posit(code); 7. return singleton; 8. 9. private int code; 10. private SafeDeposit(int c) code = c; 11. int getCode() return code; 12. 13. public class BeSafe 14. / insert lots of code here 25. Which are true? (Choose all that apply.)(分数:2.50)A.Compilation fails.B.Class BeSafe can create many instances of SafeDeposit.C.Class BeSafe CANNOT create any instances o

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