资源预览内容
第1页 / 共8页
第2页 / 共8页
第3页 / 共8页
第4页 / 共8页
第5页 / 共8页
第6页 / 共8页
第7页 / 共8页
第8页 / 共8页
亲,该文档总共8页全部预览完了,如果喜欢就下载吧!
资源描述
. 天丽科技 JAVA高级程序员选择题 1:1. Whatwillbetheresultofexecutingthefollowingcode? 2. booleana=true; 3. booleanb=false; 4. booleanc=true; 5. if(a=true) 6. if(b=true) 7. if(c=trueSomethingsaretrueinthisworld); 8. elseNothingistrueinthisworld!); 9. elseifItstooconfusingtotellwhatistrueandwhatisfalse); 10. elseHeythiswontcompile); 11. 12. Choices:What will be the result of executing the following code? boolean a = true; boolean b = false; boolean c = true; if (a = true) if (b = true)Choices:A.The code wont compile B.Some things are true in this world will be printed C.Hey this wont compile will be printed D.None of these 2: 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. 3:1. Whatwillhappenwhenyouattempttocompileandrunthefollowingcode? 2. 3. classBase 4. 5. 6. 7. inti=99; 8. 9. publicvoidamethod() 10. 11. 12. 13. Base.amethod(); 14. 15. 16. 17. Base() 18. 19. 20. 21. amethod(); 22. 23. 24. 25. 26. 27. publicclassDerivedextendsBase 28. 29. 30. 31. inti=-1; 32. 33. 34. 35. publicstaticvoidmain(Stringargv) 36. 37. 38. 39. Baseb=newDerived(); 40. 41.42. 43. b.amethod(); 44. 45. 46. 47. publicvoidamethod() 48. 49. 50. 51. Derived.amethod(); 52. 53. 54. 55. 56. 57. Choices:What will happen when you attempt to compile and run the following code? class Base int i = 99; public void amethod() Base() amethod(); public class Derived extends Baseint i = -1;public static void main(String argv) Base b = new Derived(); b.amethod(); public void amethod() Choices:C.Compile time error 4:A class design requires that a member variable should be accessible only by same package, which modifer word should be used? A.protected B.public C.no modifer D.private 5:假定a和b为int型变量,则执行下述语句组后,b的值为 a=1; b=10; do b-=a; a+; while (b-0); A.9 B.-2 C.-1 D.8 6:1. Whatresultsfromattemptingtocompileandrunthefollowingcode? 2. 3. publicclassTernary 4. 5. 6. 7. publicstaticvoidmain(Stringargs) 8. 9. 10. 11. inta=5; 12. 13. Valueis-+(a5)?9.9:9); 14. 15. 16. 17. 18. 19. Choices:What results from attempting to compile and run the following code? public class Ternarypublic static void main(String args)int a = 5; Choices:A.prints: Value is - 9 B.Compilation error C. prints: Value is - 5 D.None of these 7: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; 8: 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. 9:1. Givethefollowingjavaclass: 2. publicclassExample 3. staticintx=newint15; 4. publicstaticvoidmain(Stringargs) 5. 5); 6. 7. 8. Whichstatementiscorrected?Give the following java class:public class Examplestatic int x=new int15;public static void main(String arg
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号