欢迎来到麦多课文档分享! | 帮助中心 海量文档,免费浏览,给你所需,享你所想!
麦多课文档分享
全部分类
  • 标准规范>
  • 教学课件>
  • 考试资料>
  • 办公文档>
  • 学术论文>
  • 行业资料>
  • 易语言源码>
  • ImageVerifierCode 换一换
    首页 麦多课文档分享 > 资源分类 > DOC文档下载
    分享到微信 分享到微博 分享到QQ空间

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

    • 资源ID:1336852       资源大小:154KB        全文页数:37页
    • 资源格式: DOC        下载积分:5000积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    二维码
    微信扫一扫登录
    下载资源需要5000积分(如需开发票,请勿充值!)
    邮箱/手机:
    温馨提示:
    如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如需开发票,请勿充值!如填写123,账号就是123,密码也是123。
    支付方式: 支付宝扫码支付    微信扫码支付   
    验证码:   换一换

    加入VIP,交流精品资源
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

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

    1、计算机 Java认证-3 及答案解析(总分:100.00,做题时间:90 分钟)一、不定项选择题(总题数:44,分数:100.00)1.Concerning Java“s Garbage Collector (GC), which are true? (Choose all that apply.)(分数:1.50)A.If Object X has a reference to Object Y, then Object Y cannot be GCed.B.A Java program can request that the GC runs, but such a request doe

    2、s NOT guarantee that the GC will actually run.C.If the GC decides to delete an object, and if finalize() has never been invoked for that object, it is guaranteed that the GC will invoke finalize() for that object before the object is deleted.D.Once the GC invokes finalize() on an object, it is guara

    3、nteed that the GC will delete that object once finalize() has completed.E.When the GC runs, it decides whether to remove objects from the heap, the stack, or both.2.Given: 1. public class BackHanded 2. int state = 0; 3. BackHanded(int s) state = s; 4. public static void main(String. hi) 5. BackHande

    4、d b1 = new BackHanded(1); 6. BackHanded b2 = new BackHanded(2); 7. System.out.println(b1.go(b1) + “ “ + b2.go(b2); 8. 9. int go(BackHanded b) 10. if(this.state = 2) 11. b.state = 5; 12. go(this); 13. 14. return +this.state; 15. What is the result?(分数:1.50)A.1 2B.1 3C.1 6D.1 7E.2 6F.2 7G.Compilation

    5、fails.H.An exception is thrown at runtime.3.Given: 42. String s = “; 43. if(011 = 9) s += 4; 44. if(0x11 = 17) s += 5; 45. Integer I = 12345; 46. if(I.intValue() = Integer.valueOf(“12345“) s += 6; 47. System.out.println(s); What is the result?(分数:1.50)A.5B.45C.46D.56E.456F.Compilation fails.G.An exc

    6、eption is thrown at runtime.4.Given: 3. class Sport 4. Sport play() System.out.print(“play “); return new Sport(); 5. Sport play(int x) System.out.print (“play x “); return new Sport(); 6. 7. class Baseball extends Sport 8. Baseball play() System.out.print(“baseball “); return new Baseball(); 9. Spo

    7、rt play(int x) System.out.print(“sport “); return new Sport(); 10. 11. public static void main(String args) 12. new Baseball() .play(); 13. new Baseball() .play(7); 14. super.play (7); 15. new Sport().play(); 16. Sport s = new Baseball(); 17. s.play(); 18. What is the result?(分数:1.50)A.baseball spor

    8、t sport play playB.baseball sport play x play sportC.baseball sport play x play baseballD.Compilation fails due to a single error.E.Compilation fails due to errors on more than one line.5.Given: 2. public class Self extends Thread 3. public static void main(String args) 4. try 5. Thread t = new Thre

    9、ad(new Self(); 6. t.start(); 7. t.start(); 8. catch (Exception e) System.out.print(“e “); 9. 10. public void run() 11. for(int i = 0; i 2; i+) 12. System.out.print(Thread.currentThread() .getName() + “ “ ); 13. Which are true? (Choose all that apply.)(分数:1.50)A.Compilation fails.B.No output is produ

    10、ced.C.The output could be Thread-1 Thread-1 eD.The output could be Thread-1 e Thread-1E.The output could be Thread-1 Thread-1 Thread-2 Thread-2F.The output could be Thread-1 Thread-2 Thread-1 Thread-2G.The output could be Thread-1 Thread-1 Thread-1 Thread-16.Given: 3. class Stereo void makeNoise() a

    11、ssert true; 4. public class BoomBox2 extends Stereo 5. public static void main(String args) 6. new BoomBox2() .go(args); 7. 8. void go(String args) 9. if(args.length 0) makeNoise(); 10. if(args0 .equals(“x“) System.out.print(“x “); 11. if(args0 = “x“) System.out.println(“x2 “); 12. And (if the code

    12、compiles), the invocation: java -ea Boombox2 x What is the result?(分数:1.50)AxB.xx2C.An Error is thrown at runtime.D.Compilation fails due to an error on line 3.E.Compilation fails due to an error on line 8.F.Compilation fails due to an error on line 9.7.Given: 2. import java.util.*; 3. public class

    13、Olives 4. public static void main(String args) 5. SetInteger s = new TreeSetInteger(); 6. s.add(23); s.add(42); s.add(new Integer(5); 7. Iterator i = s.iterator(); 8. / while(System.out.print(i.next() 9. / for(Integer i2: i) System.out.print(i2); 10. / for(Integer i3: s) System.out.print(i3); 11. /

    14、while(i.hasNext() System.out.print(i.get(); 12. / while(i.hasNext() System.out.print(i.next(); 13. If lines 8-12 are uncommented, independently, which are true? (Choose all that apply.)(分数:1.50)A.Line 8 will compile.B.Line 9 will compile.C.Line 10 will compile.D.Line 11 will compile.E.Line 12 will c

    15、ompile.F.Of those that compile, the output will be 23425G.Of those that compile, the output will be 523428.Given the proper import statements and: 23. try 24. File file = new File(“myFile.txt“); 25. PrintWriter pw = new PrintWriter(file); 26. pw.println(“line 1“); 27. pw.close(); 28. PrintWriter pw2

    16、 = new PrintWriter(“myFile.txt“); 29. pw2.println(“line 2“); 30. pw2.close(); 31. catch (IOException e) What is the result? (Choose all that apply.)(分数:1.50)A.No file is created.B.A file named “myFile.txt“ is created.C.Compilation fails due to an error on line 24.D.Compilation fails due to an error

    17、on line 28.E.“myFile.txt“ contains only one line of data, “line 1“F.“myFile.txt“ contains only one line of data, “line 2“G.“myFile.txt“ contains two lines of data, “line 1“ then “line 2“9.Given this code in a method: 3. String s = “-“; 4. boolean b = false; 5. int x = 7, y = 8; 6. if(x 8) (b = true)

    18、 s + “; 7. if(! (x 8) | +y 5) s += “|“; 8. if(+y 9 9. if(y % 8 1 | y / (x - 7) 1) s += “%“; 10. System.out.println(s); What is the result?(分数:1.50)A.-B.-|%C.-|%D.-| 5. protected int y = 3; 6. private static int m1 = 4; 7. protected static int m2 = 5; 8. public static void main(String args) 9. int x

    19、= 6; int y = 7; 10. int m1 = 8; int m2 = 9; 11. new Limits().new Secret().go(); 12. 13. class Secret 14. void go() System.out.println(x + “ “ + y + “ “ + m1 + “ “ + m2); 15. What is the result?(分数:1.50)A.2 3 4 5B.2 7 4 9C.6 3 8 4D.6 7 8 9E.Compilation fails due to multiple errors.F.Compilation fails

    20、 due only to an error on line 11.G.Compilation fails due only to an error on line 14.11.Given: 3. import java.io.*; 4. class ElectronicDevice ElectronicDevice() System.out.print(“ed “); 5. class Mp3player extends ElectronicDevice implements Serializable 6. Mp3player() System.out.print(“mp “); 7. 8.

    21、class MiniPlayer extends Mp3player 9. MiniPlayer() System.out.print(“mini “); 10. public static void main(String args) 11. MiniPlayer m = new MiniPlayer(); 12. try 13. FileOutputStream fos = new FileOutputStream(“dev.txt“); 14. ObjectOutputStream os = new ObjectOutputStream(fos); 15. os.writeObject(

    22、m); os.close(); 16. FileInputStream fis = new FileInputStream(“dev.txt“); 17. ObjectInputStream is = new ObjectInputStream(fis); 18. MiniPlayer m2 = (MiniPlayer) is.readObject(); is.close(); 19. catch (Exception x) System.out.print(“x “); 20. What is the result?(分数:2.50)A.ed mp miniB.ed mp mini edC.

    23、ed mp mini ed miniD.ed mp mini ed mp miniE.Compilation fails.F.“ed mp mini“, followed by an exception.12.Given: 2. abstract interface Pixie 3. abstract void sprinkle(); 4. static int dust = 3; 5. 6. abstract class TinkerBell implements Pixie 7. String fly() return “flying “; 8. 9. public class ForRe

    24、al extends TinkerBell 10. public static void main(String args) 11. new ForReal() .sprinkle(); 12. 13. public void sprinkle() System.out.println(fly() + “ “ + dust); 14. What is the result? (Choose all that apply.)(分数:2.50)A.flying 3B.Compilation fails because TinkerBell doesn“t properly implement Pi

    25、xie.C.Compilation fails because ForReal doesn“t properly extend TinkerBell.D.Compilation fails because Pixie is not a legal interface.E.Compilation fails because ForReal doesn“t properly implement Pixie.F.Compilation fails because TinkerBell is not a legal abstract class.13.Given: 2. public class Er

    26、rrrr 3. static String a = null; 4. static String s = “; 5. public static void main(String args) 6. try 7. a = args0; 8. System.out.print(a); 9. s += “t1 “; 10. 11. catch (RuntimeException re) s += “c1 “; 12. finally s += “f1 “; 13. System.out.println(“ “ + s); 14. And two command-line invocations: j

    27、ava Errrrr java Errrrr x What is the result?(分数:2.50)A.First: f1, then: x t1B.First: f1, then: x t1 f1C.First: c1, then: x t1D.First: c1, then: x t1 f1E.First: c1 f1, then: x t1F.First: c1 f1, then: x t1 f1G.Compilation fails.14.Given: 51. String s = “4.5x4.a.3“; 52. String tokens = s.split(“/s“); 5

    28、3. for(String o: tokens) 54. System.out.print (o + “ “); 55. 56. System.out.print(“ “); 57. tokens = s.split(“/“); 58. for(String o: tokens) 59. System.out.print(o + “ “); What is the result?(分数:2.50)A.4x4B.4x4.C.4x4 3D.45x4 a 3 4x4E.4.5x4.a.3 4x4F.4.5x4.a.3 4x4.15.Given: 2. abstract class Too1 3. i

    29、nt SKU; 4. abstract void getSKU(); 5. 6. public class Hammer 7. / insert code here 8. Which line(s), inserted independently at line 7, will compile? (Choose all that apply.)(分数:2.50)A.void getSKU() ; B.private void getSKU() ; C.protected void getSKU() ; D.public void getSKU() ; 16.Given: 3. public c

    30、lass Stubborn implements Runnable 4. static Thread t1; 5. static int x = 5; 6. public void run() 7. if(Thread.currentThread() .getId() = t1.getId() shove(); 8. else push(); 9. 10. static synchronized void push() shove(); 11. static void shove() 12. synchronized (Stubborn. class) 13. System.out.print

    31、(x- + “ “); 14. try Thread.sleep(2000); catch (Exception e) ; 15. if(x 0) push(); 16. 17. public static void main(String args) 18. t1 = new Thread(new Stubborn(); 19. t1.start(); 20. new Thread(new Stubborn() .start(); 21. Which are true? (Choose all that apply.)(分数:2.50)A.Compilation fails.B.The ou

    32、tput is 5 4 3 2 1C.The output is 5 4 3 2 1 0D.The program could deadlock.E.The output could be 5, followed by deadlock.F.If the sleep() invocation was removed, the chance of deadlock would decrease.G.As it stands, the program can“t deadlock, but if shove() was changed to synchronized, then the progr

    33、am could deadlock.17.Given: 2. class Super 3. static String os = “; 4. void doStuff() os += “super “; 5. 6. public class PolyTest extends Super 7. public static void main(String args) new PolyTest().go(); 8. void go() 9. Super s = new PolyTest(); 10. PolyTest p = (PolyTest)s; 11. p.doStuff(); 12. s.

    34、doStuff(); 13. p.doPoly(); 14. s.doPoly(); 15. System.out.println(os); 16. 17. void doStuff() os += “over “; 18. void doPoly() os += “poly “; 19. What is the result?(分数:2.50)A.Compilation fails.B.over over poly polyC.over super poly polyD.super super poly polyE.An exception is thrown at runtime.18.G

    35、iven two files: 1. package com. wickedlysmart; 2. import com.wickedlysmart2.*; 3. public class Launcher 4. public static void main(String args) 5. Utils u = new Utils(); 6. u.do1(); 7. u.do2(); 8. u.do3(); 9. and the correctly compiled and located: 1. package com.wickedlysmart2; 2. class Utils 3. vo

    36、id do1() System.out.print(“dol “); 4. protected void do2() System.out.print(“do2 “); 5. public void do3() System.out.print(“do3 “); 6. What is the result for Launcher? (Choose all that apply.)(分数:2.50)A.do1 do2 do3B.“do1 “, followed by an exceptionC.Compilation fails due to an error on line 5 of Lau

    37、ncher.D.Compilation fails due to an error on line 6 of Launcher.E.Compilation fails due to an error on line 7 of Launcher.F.Compilation fails due to an error on line 8 of Launcher.19.Given: 2. public class Wacky 3. public static void main(String args) 4. int x = 5; 5. int y = (x 6) ? 7 : 8; 6. Syste

    38、m.out.print(y + “ “); 7. boolean b = (x 6) ? false : true; 8. System. out .println (b + “ “); 9. assert(x 6) : “bob“; 10. assert( (x 6) ? false : true) ) : “fred“; 11. And, if the code compiles, the invocation: java -ea Wacky Which will be contained in the output? (Choose all that apply.)(分数:2.50)A.

    39、7B.8C.bobD.fredE.trueF.falseG.Compilation fails.20.Given: 3. class MotorVehicle 4. protected int doStuff(int x) return x * 2; 5. 6. class Bicycle 7. void go(MotorVehicle m) 8. System.out.print(m. doStuff (21) + “ “); 9. 10. public class Beemer extends MotorVehicle 11. public static void main(String

    40、args) 12. System.out.print(new Beemer().doStuff(11) + “ “); 13. new Bicycle().go(new Beemer(); 14. new Bicycle() .go(new MotorVehicle(); 15. 16. int doStuff(int x) return x * 3; 17. What is the result? (Choose all that apply.)(分数:2.50)A.22 42 42B.22 63 63C.33 42 42D.33 63 42E.Compilation fails.F.An

    41、exception is thrown at runtime.21.Which are true? (Choose all that apply.)(分数:2.50)A.A single JAR file can contain only files from a single package.B.A JAR file can be used only on the machine on which it was created.C.When javac is using files within a JAR file, it will unJAR the file during compil

    42、ation.D.The Java SDK installation directory tree on a Java developer“s computer usually includes a subdirectory tree named jre/lib/ext.E.A JAR file is structured so that all the files and directories that you“ve “JARed“ will be subdirectory(ies) of the META-INF directory.F.When javac is invoked with

    43、 a classpath option, and you need to find files in a JAR file, the name of the JAR file must be included at the end of the path.22.Given the proper import(s), and given: 13. class NameCompare implements ComparatorStuff 14. public int compare(Stuff a, Stuff b) 15. return pareTo(a.name); 16. 18. class

    44、 ValueCompare implements ComparatorStuff 19. public int compare(Stuff a, Stuff b) 20. return (a.value - b.value); 21. Which are true? (Choose all that apply.)(分数:2.50)A.This code does not compile.B.This code allows you to use instances of Stuff as keys in Maps.C.These two classes properly implement

    45、the Comparator interface.D.NameCompare allows you to sort a collection of Stuff instances alphabetically.E.ValueCompare allows you to sort a collection of Stuff instances in ascending numeric order.F.If you changed both occurrences of “compare()“ to “compareTo()“, the code would compile.23.Given: 3.

    46、 public class Chopper 4. String a = “12b“; 5. public static void main(String args) 6. System.out.println (new Chopper().chop(args0); 7. 8. int chop(String a) 9. if(a = null) throw new IllegalArgumentException(); 10. return Integer.parseInt(a); 11. And, if the code compiles, the invocation: java Chop

    47、per What is the result?(分数:2.50)A.12B.12bC.Compilation fails.D.A NullPointerException is thrown.E.A NumberFormatException is thrown.F.An IllegalArgumentException is thrown.G.An ArrayIndexOutOfBoundsException is thrown.24.Which, concerning command-line options, are true? (Choose all that apply.)(分数:2

    48、.50)A.The -D flag is used in conjunction with a name-value pair.B.The -D flag can be used with javac to set a system property.C.The -d flag can be used with java to disable assertions.D.The -d flag can be used with javac to specify where to place .class files.E.The -d flag can be used with javac to document the locations of deprecated APIs in source files.25.Given that “it, IT“ is the locale code for Italy and that “pt, BR“ is the


    注意事项

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




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

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

    收起
    展开