




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
选择题 1: 1. Whatwillbetheresultofexecutingthefollowingcode? 2. 3. publicstaticvoidmain(Stringargs) 4. 5. chardigit=a; 6. for(inti=0;i10;i+) 7. 8. switch(digit) 9. 10. casex: 11. 12. intj=0; 13. System.out.println(j); 14. 15. default: 16. 17. intj=100; 18. System.out.println(j); 19. 20. 21. 22. inti=j; 23. System.out.println(i); 24. 25. 26. Choices:What will be the result of executing the following code? public static void main(String args) char digit = a; for (int i = 0; i 4) 3. System.out.println(“Test1”); 4. elseif(x9) 5. System.out.println(“Test2”); 6. else 7. System.out.println(“Test3”); 8. Whichrangeofvaluexwouldproduceofoutput“Test2”?Give the code fragment:if(x4)System.out.println(“Test 1”);else if (x9)System.out.println(“Test 2”);else System.out.println(“Test 3”);Which range of value x would produce of output “Test 2”? A.x4 C.x9 D.None 3:关于垃圾收集的哪些叙述是对的。 A.程序开发者必须自己创建一个线程进行内存释放的工作。 B.垃圾收集将检查并释放不再使用的内存。 C.垃圾收集允许程序开发者明确指定并立即释放该内存。 D.垃圾收集能够在期望的时间释放被java对象使用的内存。 4: 1. Givethefollowingmethod: 2. publicvoidmethod() 3. Stringa,b; 4. a=newString(“helloworld”); 5. b=newString(“gameover”); 6. System.out.println(a+b+”ok”); 7. a=null; 8. a=b; 9. System.out.println(a); 10. 11. Intheabsenceofcompileroptimization,whichistheearliestpointtheobjectareferedisdefinitelyelibiletobegarbagecollection.Give the following method: public void method( ) String a,b; a=new String(“hello world”); b=new String(“game over”); System.out.println(a+b+”ok”); a=null; a=b; System.out.println(a); In the absence of compiler optimization, which is the earliest point the object a refered is definitely elibile to be garbage collection.A.before line 5 B.before line 6 C.before line 7 D.before line 9 5: 1. Strings=”ExampleString”;Whichoperationisnotlegal?String s=”Example String”;Which operation is not legal?A.int i=s.length(); B.s3=”x”; C.String short_s=s.trim(); D.String t=”root”+s; 6:Which method you define as the starting point of new thread in a class from which new the thread can be excution? A.public void start() B.public void run() C.public void runnable() D.public static void main(String args) 7: 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. 8:Which statements about Java code security are not true? A.The bytecode verifier loads all classes needed for the execution of a program. B.Executing code is performed by the runtime interpreter. C.At runtime the bytecodes are loaded, checked and run in an interpreter. D.The class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources. 9:下面关于变量及其范围的陈述哪些是错的。 A.实例变量是类的成员变量。 B.实例变量用关键字static声明。 C.在方法中定义的局部变量在该方法被执行时创建 D.局部变量在使用前必须被初始化。 10: 1. Givethefollowingjavasourcefragement: 2. /pointx 3. publicclassInteresting 4. /dosomething 5. 6. WhichstatementiscorrectlyJavasyntaxatpointx?Give the following java source fragement:/point xpublic class Interesting/do somethingWhich statement is correctly Java syntax at point x? A.public class MyClass/do other thing B.static int PI=3.14 C.class MyClass/do something D.none 11: 1. Whatwillhappenwhenyouattempttocompileandrunthefollowingcode? 2. 3. (Assumethatthecodeiscompiledandrunwithassertionsenabled.) 4. 5. publicclassAssertTest 6. 7. publicvoidmethodA(inti) 8. 9. asserti=0:methodB(); 10. 11. System.out.println(i); 12. 13. 14. 15. publicvoidmethodB() 16. 17. System.out.println(Thevaluemustnotbenegative); 18. 19. 20. 21. publicstaticvoidmain(Stringargs) 22. 23. AssertTesttest=newAssertTest(); 24. 25. test.methodA(-10); 26. 27. 28. 29. What will happen when you attempt to compile and run the following code?(Assume that the code is compiled and run with assertions enabled.)public class AssertTestpublic void methodA(int i)assert i = 0 : methodB();System.out.println(i);public void methodB() System.out.println(The value must not be negative);public static void main(String args)AssertTest test = new AssertTest();test.methodA(-10); A.it will print -10 B.it will result in AssertionError showing the message-“the value must not be negative”. C.the code will not compile. D.None of these. 12: 1. Givethefollowingcode: 2. publicclassExample 3. publicstaticvoidmain(Stringargs) 4. intl=0; 5. do 6. System.out.println(“Doingitforlis:”+l); 7. while(-l0) 8. System.out.println(“Finish”); 9. 10. 11. Whichwellbeoutput:Give the following code:public class Examplepublic static void main(String args )int l=0;doSystem.out.println(“Doing it for l is:”+l);while(-l0)System.out.println(“Finish”);Which well be output: A.Doing it for l is 3 B.Doing it for l is 1 C.Doing it for l is 2 D.Doing it for l is 0 13:假定a和b为int型变量,则执行下述语句组后,b的值为 a=1; b=10; do b-=a; a+; while (b-0); A.9 B.-2 C.-1 D.8 14: 1. 1.publicclassX 2. 2.publicobjectm() 3. 3.objecto=newfloat(3.14F); 4. 4.objectoa=newobject1; 5. 5.oa0=o; 6. 6.o=null; 7. 7.oa0=null; 8. 8.returno; 9. 9. 10. 10. 11. Whenisthefloatobjectcreatedinline3,eligibleforgarbagecollection? 1. public class X 2. public object m () 3. object o = new float (3.14F); 4. object oa = new object 1; 5. oa0= o; 6. o = null; 7. oa0 = null; 8.return o; 9. 10. 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 D.Just after line 8(that is, as the method returns) 15: 1. Whatistheresultwhenyoucompileandrunthefollowingcode? 2. 3. publicclassThrowsDemo 4. 5. 6. 7. staticvoidthrowMethod() 8. 9. 10. 11. System.out.println(InsidethrowMethod.); 12. 13. thrownewIllegalAccessException(demo); 14. 15. 16. 17. 18. 19. publicstaticvoidmain(Stringargs) 20. 21. 22. 23. try 24. 25. 26. 27. throwMethod(); 28. 29. 30. 31. catch(IllegalAccessExceptione) 32. 33. 34. 35. System.out.println(Caught+e); 36. 37. 38. 39. 40. 41. 42. 43. Choices:What is the result when you
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2023六年级数学上册 二 比和比例 1比第1课时 比的意义说课稿 冀教版
- 四种挺水植物浸提液对铜绿微囊藻的化感作用及对富营养化水体的修复
- 土石方机械设备运维方案
- 城边村集中供热改造工程节能评估报告
- 考点解析人教版八年级上册物理声现象《声音的特性》定向攻克试卷(含答案解析)
- 考点解析-人教版八年级物理《浮力》同步训练试题(含详解)
- 考点解析人教版八年级上册物理物态变化《温度》专项训练试卷(附答案详解)
- 达标测试人教版八年级上册物理《物态变化》综合测试试题(含详解)
- 八年级体育 蹲距式跳远-助跑与踏跳相结合技术说课稿
- 难点详解人教版八年级上册物理光现象《光的反射》同步练习试卷(含答案解析)
- DB32T 5192-2025工业园区碳排放核算指南
- 2025年《高级汽车维修工》考试练习题及答案
- 农村小学安全培训知识课件
- 2025年工程项目管理试题及答案
- 人力资源部安全工作总结
- 桥梁工程技术总结报告合集
- 第6课 书衣之美说课稿初中美术沪书画版五四学制2024六年级上册-沪书画版五四学制2024
- 心血管疾病预防规定
- 陈明主讲中医妇科经验方
- 毕业论文:电气自动化技术毕业论文
- 教改项目项目结项汇报
评论
0/150
提交评论