【计算机类职业资格】计算机Java认证-3及答案解析.doc
《【计算机类职业资格】计算机Java认证-3及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】计算机Java认证-3及答案解析.doc(37页珍藏版)》请在麦多课文档分享上搜索。
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
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 JAVA 认证 答案 解析 DOC
