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