北京赛博商达科技有限公司_第1页
北京赛博商达科技有限公司_第2页
北京赛博商达科技有限公司_第3页
北京赛博商达科技有限公司_第4页
北京赛博商达科技有限公司_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

选择题 1:以下的C程序代码片段运行后C和d的值分别是多少 Int a =1,b =2; Int c,d; c =(a&b)&a; d =(a&b)&a; A.0,0 B.0,1 C.1,0 D.1,1 2: 1. publicclassX 2. 3. publicObjectm() 4. 5. Objecto=newFloat(3.14F);/line3 6. 7. Objectoa=newObject1;/line4 8. 9. oa0=o;/line5 10. 11. o=null;/line6 12. 13. returnoa0;/line7 14. 15. 16. 17. 18. WhenistheFloatobject,createdinline3,eligibleforgarbagecollection?public class X public Object m() Object o = new Float(3.14F);/line 3 Object oa = new Object1;/line 4 oa0 = o;/line 5 o=null;/line 6 return oa0;/line 7 When is the Float object, created in line 3,eligible for garbage collection?A.just after line 5. B.just after line 6 C.just after line 7(that is,as the method returns) D.never in this method 3: 1. 给出下面的代码片断。下面的哪些陈述为错误的? 2. 1)publicvoidcreate() 3. 2)VectormyVect; 4. 3)myVect=newVector(); 5. 4)给出下面的代码片断。下面的哪些陈述为错误的?1) public void create() 2) Vector myVect;3) myVect = new Vector();4) A.第二行的声明不会为变量myVect分配内存空间。 B.第二行语句创建一个Vector类对象。 C.第三行语句创建一个Vector类对象。 D.第三行语句为一个Vector类对象分配内存空间 4: Consider the class hierarchy shown below: - class FourWheeler implements DrivingUtilities class Car extends FourWheeler class Truck extends FourWheeler class Bus extends FourWheeler class Crane extends FourWheeler - Consider the following code below: 1.DrivingUtilities du; 2.FourWheeler fw; 3.Truck myTruck = new Truck(); 4.du = (DrivingUtilities)myTruck; 5.fw = new Crane(); 6.fw = du; Which of the statements below are true? Choices: A.Line 4 will not compile because an interface cannot refer to an object. B.The code will compile and run. C.The code will not compile without an explicit cast at line 6, because going down the hierarchy without casting is not allowed. D.The code will compile if we put an explicit cast at line 6 but will throw an exception at runtime. 5: 1. Whichisthemostappropriatecodesnippetthatcanbeinsertedatline18inthefollowingcode? 2. 3. (Assumethatthecodeiscompiledandrunwithassertionsenabled) 4. 5. 1.importjava.util.*; 6. 7. 2. 8. 9. 3.publicclassAssertTest 10. 11. 4. 12. 13. 5.privateHashMapcctld; 14. 15. 6. 16. 17. 7.publicAssertTest() 18. 19. 8. 20. 21. 9.cctld=newHashMap(); 22. 23. 10.cctld.put(in,India); 24. 25. 11.cctld.put(uk,UnitedKingdom); 26. 27. 12.cctld.put(au,Australia); 28. 29. 13./morecode. 30. 31. 14. 32. 33. 15./othermethods. 34. 35. 16.publicStringgetCountry(StringcountryCode) 36. 37. 17. 38. 39. 18./Whatshouldbeinsertedhere? 40. 41. 19.Stringcountry=(String)cctld.get(countryCode); 42. 43. 20.returncountry; 44. 45. 21. 46. 47. 22.Which is the most appropriate code snippet that can be inserted at line 18 in the following code?(Assume that the code is compiled and run with assertions enabled)1. import java.util.*;2. 3. public class AssertTest4. 5. private HashMap cctld;6. 7. public AssertTest()8. 9. cctld = new HashMap();10. cctld.put(in, India);11. cctld.put(uk, United Kingdom);12. cctld.put(au, Australia);13. / more code. 14. 15. / other methods . 16. public String getCountry(String countryCode)17. 18. / What should be inserted here?19. String country = (String)cctld.get(countryCode);20. return country;21. 22. A.assert countryCode != null; B.assert countryCode != null : Country code can not be null ; C.assert cctld != null : No country code data is available; D.assert cctld : No country code data is available; 6:关于垃圾收集的哪些叙述是对的。 A.程序开发者必须自己创建一个线程进行内存释放的工作。 B.垃圾收集将检查并释放不再使用的内存。 C.垃圾收集允许程序开发者明确指定并立即释放该内存。 D.垃圾收集能够在期望的时间释放被java对象使用的内存。 7:Use the operator “” and “”. Which statement is true? A.1010 0000 0000 0000 0000 0000 0000 0000 4 give 0000 1010 0000 0000 0000 0000 0000 0000 B.1010 0000 0000 0000 0000 0000 0000 0000 4 give 1111 1010 0000 0000 0000 0000 0000 0000 C.1010 0000 0000 0000 0000 0000 0000 0000 4 give 0000 0000 0000 0000 0000 0000 0000 0000 D.1010 0000 0000 0000 0000 0000 0000 0000 4 give 1111 1010 0000 0000 0000 0000 0000 0000 8:Which statement about the garbage collection mechanism are true? A.Garbage collection require additional programe code in cases where multiple threads are running. B.The programmer can indicate that a reference through a local variable is no longer of interest. C.The programmer has a mechanism that explicity and immediately frees the memory used by Java objects. D.The garbage collection mechanism can free the memory used by Java Object at explection time. 9:使用 JDBC 可以做到的是 A.把二进制代码传送到任何关系数据库中 B.把 Java 源代码传送到任何关系数据库中 C.把表单信息传送到任何关系数据库中 D.很容易地把 SQL 语句传送到任何关系数据库中 10: 1. Whatistheresultwhenyoucompileandrunthefollowingcode? 2. 3. publicclassTest 4. 5. 6. 7. publicvoidmethod() 8. 9. 10. 11. for(inti=0;i3;i+) 12. 13. 14. 15. System.out.print(i); 16. 17. 18. 19. System.out.print(i); 20. 21. 22. 23. 24. 25. Choices:What is the result when you compile and run the following code? public class Test public void method()for(int i = 0; i 3; i+) System.out.print(i); System.out.print(i); Choices:A.0122 B.0123 C.Compilation error D.None of these 11: 1. ThefollowingcodeisentirecontentsofafilecalledExample.java,causespreciselyoneerrorduringcompilation: 2. classSubClassextendsBaseClass 3. 4. classBaseClass() 5. Stringstr; 6. publicBaseClass() 7. System.out.println(“ok”); 8. publicBaseClass(Strings) 9. str=s; 10. publicclassExample 11. publicvoidmethod() 12. SubClasss=newSubClass(“hello”); 13. BaseClassb=newBaseClass(“world”); 14. 15. 16. 17. Whichlinewouldbecausetheerror?The following code is entire contents of a file called Example.java,causes precisely one error during compilation: class SubClass extends BaseClass class BaseClass() String str; public BaseClass() System.out.println(“ok”); public BaseClass(String s) str=s; public class Example public void method() SubClass s=new SubClass(“hello”); BaseClass b=new BaseClass(“world”); Which line would be cause the error? A.9 B.10 C.11 D.12 12: 1. Whatwillbetheresultofexecutingthefollowingcode? 2. 3. /Filename;SuperclassX.java 4. 5. packagepackageX; 6. 7. publicclassSuperclassX 8. 9. 10. 11. protectedvoidsuperclassMethodX() 12. 13. 14. 15. 16. 17. intsuperclassVarX; 18. 19. 20. 21. 22. 23. /FilenameSubclassY.java 24. 25. 1.packagepackageX.packageY; 26. 27. 2. 28. 29. 3.publicclassSubclassYextendsSuperclassX 30. 31. 4. 32. 33. 5.SuperclassXobjX=newSubclassY(); 34. 35. 6.SubclassYobjY=newSubclassY(); 36. 37. 7.voidsubclassMethodY() 38. 39. 8. 40. 41. 9.objY.superclassMethodX(); 42. 43. 10.inti; 44. 45. 11.i=objY.superclassVarX; 46. 47. 12. 48. 49. 13. 50. 51. Choices:What will be the result of executing the following code? / Filename; SuperclassX.javapackage packageX; public class SuperclassXprotected void superclassMethodX()int superclassVarX; / Filename SubclassY.java1.package packageX.packageY;2.3.public class SubclassY extends SuperclassX4.5.SuperclassX objX = new SubclassY();6.SubclassY objY = new SubclassY();7.void subclassMethodY()8.9.objY.superclassMethodX();10.int i;11.i = objY.superclassVarX;12.13. Choices:A.Compilation error at line 5 B.Compilation error at line 9 C.Runtime exception at line 11 D.None of these 13:Which of the following statements are not legal? A.long l = 4990; B.int i = 4L; C.double d = 34.4; D.double t = 0.9F. 14: 1. Givethisclassoutline: 2. classExample 3. privateintx; 4. /restofclassbody 5. 6. AssumingthatxinvokedbythecodejavaExample,whichstatementcanmadexbedirectlyaccessibleinmain()methodofExample.java?Give this class outline:class Exampleprivate int x;/rest of class bodyAssuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java?A.Change private int x to public int x B.change private int x to static int x C.Change private int x to protected int x D.change private int x to final int x 15: Which of the following statements are true? A.The automatic garbage collection of the JVM prevents programs from ever running out of memory B.A program can suggest that garbage collection be performed and force it C.Garbage collection is platform independent D.An object becomes eligible for garbage collection when all references denoting it are set to null. 简答题 16:写一个生成随机数的类(或者函数)。 1

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论