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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

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

1、计算机 Java认证-6 及答案解析(总分:100.00,做题时间:90 分钟)一、不定项选择题(总题数:42,分数:100.00)1.Given: 4. class Electricity int getCharge() return 24; 5. public class Voltage extends Electricity 6. enum volts twelve, twentyfour, oneten; 7. public static void main(String args) 8. volts v = velts.twentyfour; 9. switch (v) 10. ca

2、se twelve: 11. System.out.print(“12 “); 12. default: 13. System.out.print (getCharge() + “ “); 14. case oneten: 15. System.out.print(“110 “); 16. What is the result? (Choose all that apply.)(分数:1.50)A.24B.24 110C.24 110 12D.Compilation fails due to a misuse of enums.E.Compilation fails due to a non-

3、enum issue.2.Given: 2. import java.io.*; 3. public class Uboat 4. public static void main(String args) 5. try 6. File f1 = new File(“sub1“); 7. f1.mkdir(); 8. File f2 = new File(f1, “sub2“); 9. File f3 = new File(f1, “sub3“); 10. PrintWriter pw = new PrintWriter(f3); 11. catch (Exception e) System.o

4、ut.println(“ouch“); 12. And, if the code compiles, what is the result if “java Uboat“ is invoked TWICE? (Choose all that apply.)(分数:1.50)A.Compilation fails.B.The second invocation produces the output “ouch“.C.The second invocation creates at least one new file as a peer to the new directory.D.The f

5、irst invocation creates a new directory and one new file in that directory.E.The first invocation creates a new directory and two new files in that directory.F.The first invocation creates a new directory and at least one new file as a peer to it.3.Given: 2. class Car 3. private Car() 4. protected C

6、ar(int x) 5. 6. public class MG extends Car 7. / MG(int x) 8. / MG(int x) super(); 9. / MG(int x) super(x); 10. / private MG(int x) super(x); 11. / MG() 12. / MG() this(); 13. / MG() this(6); 14. / MG() super(7); 15. public static void main(String args) 16. new MG(7); 17. new MG(); 18. Which sets of

7、 constructors can be uncommented for the code to compile? (Choose all that apply.)(分数:1.50)A.Line 7 and line 11.B.Line 7 and line 14.C.Line 8 and line 12.D.Line 8 and line 13.E.Line 9 and line 12.F.Line 9 and line 13.G.Line 10 and line 11.H.Line 10 and line 14.4.Given: 2. interface Gadget 3. int pat

8、ent = 12345; 4. Gadget doStuff(); 5. 6. public class TimeMachine implements Gadget 7. int patent = 34567; 8. public static void main(String args) 9. new TimeMachine().doStuff(); 10. 11. TimeMachine doStuff() 12. System.out.println( +patent); 13. return new TimeMachine(); 14. If javac is invoked twic

9、e: javac -source 1.4 TimeMachine.Java javac TimeMachine. java And, if“java TimeMachine“ is invoked whenever TimeMachine compiles, what is the result?(分数:1.50)A.First, compilation fails, then 12346B.First, compilation fails, then 34568C.First, 12346, then compilation fails.D.First, 34568, then compil

10、ation fails.E.First, 12346, then 34568F.Compilation fails on both javac invocations.5.Given: 1. import java.util.*; 2. public class LogSplitter 3. public static void main(String args) 4. for(int x = i; x args.length; x+) 5. System.out.print(args0 .split(argsx) .length + “ “); 6. And the command-line

11、 invocation: java LogSplitter “x1 23 y #“ “/d“ “/s“ “/w“ What is the result?(分数:1.50)A.4 4 6B.3 3 6C.5 4 6D.4 6 4E.3 6 3F.5 6 4G.Compilation fails.H.An exception is thrown at runtime.6.Given this code in a method: 3. int y, count = 0; 4. for(int x = 3; x 6; x+) 5. try 6. switch(x) 7. case 3: count+;

12、 8. case 4: count+; 9. case 7: count+; 10. case 9: y = 7 / (x - 4); count += 10; 11. 12. catch (Exception ex) count+; 13. 14. System.out.println(count); What is the result? A. 2 B. 15 C. 16 D. 25 E. 26 F Compilation fails. G. An exception is thrown with no other output. (分数:2.50)A.B.C.D.E.F.G.7.Give

13、n: 5. abstract class Thing static String s = “; Thing() s += “t “; 6. class Steel extends Thing 7. Steel() s += “s “; 8. Steel (String s1) 9. s += s1; 10. new Steel(); 11. 12. 13. public class Tungsten extends Steel 14. Tungsten(String s1) 15. s += s1; 16. new Steel(s); 17. 18. public static void ma

14、in(String args) 19. new Tungsten(“tu “); 20. System.out.println(s); 21. What is the result?(分数:2.50)A.s tu s tu sB.t s tu t s t sC.t s tu t t s tu t sD.t tu t s tu t t tu t s tu t sE.Compilation fails.F.An exception is thrown at runtime.8.Given: 2. public class Swanky 3. Swanky s; 4. public static v

15、oid main(String args) 5. Swanky s1 = new Swanky(); 6. s1.s = new Swanky(); 7. go (s1. s); 8. Swanky s2 = go(s1); 9. if(s2.s.equals(s1) System.out.print(“1 “); 10. if(s2.equals(s1) System.out.print (“2 “); 11. if(s1.s.equals(s1) System.out.print(“3 “); 12. if(s2.s.equals(s2) System.out.print(“4 “); 1

16、3. 14. static Swanky go(Swanky s) 15. Swanky gs = new Swanky(); 16. gs.s = s; 17. return gs; 18. What is the result?(分数:2.50)A.1B.1 2C.1 2 4D.Compilation fails.E.“1 “, followed by an exception.F.“1 2 “, followed by an exception.9.Given: 2. import java.util.*; 3. public class AndOver 4. public static

17、 void main(String args) 5. List g = new ArrayList(); 6. g.add(new Gaited(“Eyra“); 7. g.add(new Gaited(“Vafi“); 8. g.add(new Gaited(“Andi“); 9. Iterator i2 = g.iterator(); 10. while(i2.hasNext() 11. System.out.print(i2.next().name + “ “); 12. 13. class Gaited 14. public String name; 15. Gaited(String

18、 n) name = n; 16. What is the result?(分数:2.50)A.Vail AndiB.Andi Eyra VailC.Andi Vail EyraD.Eyra Vail AndiE.Compilation fails.F.The output order is unpredictable.10.Given: 2. interface Plant 3. int greenness = 7; 4. void grow(); 5. 6. class Grass implements Plant 7. / static int greenness = 5; 8. / i

19、nt greenness = 5; 9. public static void main(String args) 10. int greenness = 2; 11. new Grass().grow(); 12. 13. public void grow() 14. System.out.println(+greenness); 15. Which are true? (Choose all that apply.)(分数:2.50)A.As the code stands, the output is 3.B.As the code stands, the output is 8.C.A

20、s the code stands, it will NOT compile.D.If line 7 is un-commented, the output is 6.E.If line 8 is un-commented, the output is 6.F.If line 7 is un-commented, the output is 8.G.If line 7 is un-commented, the code will NOT compile.11.Given: 2. class Grab 3. static int x = 5; 4. synchronized void adjus

21、t(Grab y) 5. System.out.print(x- + “ “); 6. y.view(y); 7. 8. synchronized void view(Grab z) if(x 0) z.adjust(z); 9. 10. public class Grapple implements Runnable 11. static Thread t1; 12. static Grab g, g2; 13. public void run() 14. if(Thread.currentThread().getId() = t1.getId() g.adjust(g2); 15. els

22、e g2.view(g); 16. 17. public static void main(String args) 18. g = new Grab(); 19. g2 = new Grab(); 20. t1 = new Thread(new Grapple(); 21. t1.start(); 22. new Thread(new Grapple().start(); 23. Which are true? (Choose all that apply.)(分数:2.50)A.Compilation fails.B.The output could be 5 4 3 2 1C.The o

23、utput could be 5 4 3 2 1 0D.The program could produce thousands of lines of output.E.The program could deadlock before producing any output.F.The output could be “5 “, followed by the program deadlocking.12.Given: 3. import java.util.*; 4. public class Corner 5. public static void main(String args)

24、6. TreeSetString t1 = new TreeSetString(); 7. TreeSetString t2 = new TreeSetString(); 8. t1.add(“b“); t1.add(“7“); 9. t2 = (TreeSet)t1.subSet(“5“, “c“); 10. try 11. t1.add(“d“); 12. t2.add(“6“); 13. t2.add(“3“); 14. 15. catch (Exception e) System.out.print(“ex “); 16. System.out.println(t1 + “ “ + t

25、2); 17. What is the result?(分数:2.50)A.6, 7, b 6, 7, bB.6, 7, b, d 6, 7, bC.ex 6, 7, b 6, 7, bD.ex 6, 7, b, d 6, 7, bE.3, 6, 7, b, d 6, 7, bF.ex 6, 7, b, d 6, 7, b, dG.Compilation fails due to error(s) in the code.13.Given the current directory is bigApp, and the directory structure: bigApp |- classe

26、s |- Cloned.class |- com |- Cloned.class |- wickedlysmart |- Cloned.class And the three files: public class Cloned public static voidmain(String args) System.out.println(“classes“); public class Cloned public static void main(String args) System.out.println(“com“); public class Cloned public static

27、void main(String args) System.out.println(“ws“); Have been compiled into the classes, com, and wickedlysmart directories, respectively. Which will produce the output “ws“? (Choose all that apply.)(分数:2.50)A.java -cp wickedlysmart:. ClonedB.java -cp classes/com/wickedlysmart ClonedC.java -cp classes/

28、com/wickedlysmart:classes ClonedD.java -cp classes:classes/corn/wickedlysmart ClonedE.java -cp .:classes/com/wickedlysmart:classes ClonedF.java -cp .:classes/com:classes/com/wickedlysmart Cloned14.Given: 1. import java.io.*; 2. public class Edgy 3. public static void main(String args) 4. try 5. wow(

29、); 6. / throw new IOException(); 7. finally 8. / throw new Error(); 9. / throw new IOException(); 10. 11. 12. static void wow() 13. / throw new IllegalArgumentException(); 14. / throw new IOException(); 15. And given that IOException is a direct subclass of java.lang.Exception, and that llegalArgume

30、ntException is a runtime exception, which of the following, if uncommented independently, will compile? (Choose all that apply.)(分数:2.50)A.Line 6B.Line 8C.Line 9D.Line 13E.Line 14F.The code will NOT compile as is.15.Given two files: 1. package com; 2. public class MyClass 3. public static void howdy

31、) System.out.print(“howdy “); 4. public static final int myConstant = 343; 5. public static final MyClass mc = new MyClass(); 6. public int instVar = 42; 7. 11. import com. MyClass; 12. public class TestImports2 13. public static void main(String args) 14. MyClass.howdy(); 15. System.out.print(MyCl

32、ass.myConstant + “ “); 16. System.out.print(myConstant + “ “); 17. howdy(); 18. System.out.print(mc.instVar + “ “); 19. System.out.print(instVar + “ “); 20. What is the result? (Choose all that apply.)(分数:2.50)A.howdy 343 343 howdy 42 42B.Compilation fails due to an error on line 14.C.Compilation fa

33、ils due to an error on line 15.D.Compilation fails due to an error on line 16.E.Compilation fails due to an error on line 17.F.Compilation fails due to an error on line 18.G.Compilation fails due to an error on line 19.16.Given this code inside a method: 13. int count = 0; 14. outer: 15. for(int x =

34、 0; x 5; x+) 16. middle: 17. for(int y = 0; y 5; y+) 18. if(y = 1) continue middle; 19. if(y = 3) break middle; 20. count+; 21. 22. if(x 2) continue outer; 23. count = count + 10; 24. 25. System.out.println(“count: “ + count); What is the result?(分数:2.50)A.count: 33B.count: 40C.count: 45D.count: 65E

35、Compilation fails.F.The code runs in an endless loop.17.Given: 2. public class OrganicE 3. void react(E e) 4. static void main(String args) 5. / Organic? extends Organic compound = new AliphaticOrganic(); 6. / Organic? super Aliphatic compound = new AliphaticOrganic(); 7. compound.react(new Organic

36、); 8. compound.react(new Aliphatic(); 9. compound.react(new Hexane(); 10. 11. class AliphaticF extends OrganicF 12. class HexaneG extends AliphaticG Which, taken independently, are true? (Choose all that apply.)(分数:2.50)A.If line 5 is uncommented, compilation fails due to an error at line 7.B.If li

37、ne 5 is uncommented, compilation fails due to an error at line 8.C.If line 5 is uncommented, compilation fails due to an error at line 9.D.If line 6 is uncommented, compilation fails due to an error at line 7.E.If line 6 is uncommented, compilation fails due to an error at line 8.F.If line 6 is unco

38、mmented, compilation fails due to an error at line 9.18.Given: 4. public class Hemlock 5. static StringBuffer sb; 6. StringBuffer sb2; 7. public static void main(String args) 8. sb = sb.append(new Hemlock().go(new StringBuffer(“hey“); 9. System.out.println(sb); 10. 11. sb2 = new StringBuffer(“hi “);

39、 12. StringBuffer go(StringBuffer s) 13. System.out.print(s + “ oh “ + sb2); 14. return new StringBuffer(“ey“); 15. 16. static sb = new StringBuffer(“yo “); 17. What is the result?(分数:2.50)A.yoeyB.hey oh hiC.hey oh hi eyD.oh hi heyE.hey oh hi yo eyF.yo hey oh hi eyG.Compilation fails.H.An exception

40、is thrown at runtime.19.Given: 1. class Hotel 2. static void doStuff(int x) 3. assert (x 0) : “hotel“; 4. 5. 6. public class Motel13 extends Hotel 7. public static void main(String args) 8. doStuff(-5); 9. int y = 0; 10. assert (y 0) : “motel“; 11. Which of the following revocations will run without

41、 exception? (Choose all that apply.)(分数:2.50)A.java Motel13B.java-ea Motel13C.java-da:Hotel Motel13D.java-da:Motel13 Motel13E.java-ea-da:Hotel Motel13F.java-ea-da:Motell3 Motel1320.Given: 3. class One 4. void go1() System.out.print(“1 “); 5. final void go2() System.out.print(“2 “); 6. private void g

42、o3() System.out.print(“3 “); 7. 8. public class OneB extends One 9. void go1() System.out.print(“ib “); 10. void go3() System.out.print(“3b “); 11. 12. public static void main(String args) 13. new OneB().go1(); 14. new One().go1(); 15. new OneB().go2(); 16. new OneB().go3(); 17. new One().go3(); 18.

43、 What is the result?(分数:2.50)A.1 1 2 3 3B.1b 1 2 3b 3C.1b 1b 2 3b 3bD.Compilation fails due to a single error.E.Compilation fails due to errors on more than one line.21.Given: 3. public class Gauntlet 4. public static void main(String args) 5. String r = “0“; 6. int x = 3, y = 4; 7. boolean test = f

44、alse; 8. if(x 2) | (test = true) 9. if(y 5) | (+x = 4) 10. if(test = true) | (+y = 4) 11. r += “i“; 12. else if(y = 5) r += “2“; 13. else r += “3“; 14. else r += “4“; 15. / else r += “5“; 16. System.out.println(r); 17. And given that, if necessary you can add line 15 to make the code compile, what i

45、s the result? (Choose all that apply.)(分数:2.50)A.At line 10, test will equal trueB.At line 10, test will equal falseC.The output will be 02D.The output will be 03E.The output will be 023F.The code will compile as is.G.The code will only compile if line 15 is added.22.Given: 2. import rt.utils.Remote

46、 3. public class Controller 4. public static void main(String args) 5. Remote remote = new Remote(); 6. And rt.utils.Remote class is properly bundled into a JAR file called rtutils.jar. And given the following steps: P. Place rtutils.jar in the $ROOT directory. Q. Extract rtutils.jar and put rt dir

47、ectory with its subdirectories in the $ROOT directory. R. Extract rtutils.jar and place Remote.class in the $ROOT directory. S. Place rtutils.jar in the $JAVA HOME/jre/lib/ext directory. X. Compile using: javac -cp rtutils.jar Controller.java Y. Compile using: javac Controller.java Z. Compile using:

48、 javac -cp. Controller.java If Controller.java resides in the $ROOT directory, which set(s) of steps will compile the Controller class? (Choose all that apply.)(分数:2.50)A.P-XB.Q-YC.R-ZD.P-ZE.R-YF.S-XG.S-Z23.Given: 2. public class Boot 3. static String s; 4. static s = “ ; 5. System.out.print(“shinier “); 6.

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