资源预览内容
第1页 / 共6页
第2页 / 共6页
第3页 / 共6页
第4页 / 共6页
第5页 / 共6页
第6页 / 共6页
亲,该文档总共6页全部预览完了,如果喜欢就下载吧!
资源描述
选择题 1: 1. What will happen when you attempt to compile and run the following code? 2. 3. class Base 4. 5. 6. 7. int i = 99; 8. 9. public void amethod() 10. 11. 12. 13. System.out.println(Base.amethod(); 14. 15. 16. 17. Base() 18. 19. 20. 21. amethod(); 22. 23. 24. 25. 26. 27.public class Derived extends Base 28. 29. 30. 31.int i = -1; 32. 33. 34. 35.public static void main(String argv) 36. 37. 38. 39. Base b = new Derived(); 40. 41. System.out.println(b.i); 42. 43. b.amethod(); 44. 45. 46. 47. public void amethod() 48. 49. 50. 51. System.out.println(Derived.amethod(); 52. 53. 54. 55. 56. 57.Choices: Error! Reference source not found.A.Derived.amethod() -1 Derived.amethod() Error! Reference source not found.B.Derived.amethod() 99 Error! Reference source not found.C.Compile time error Error! Reference source not found.D.Derived.amethod() 2:使用 JDBC 可以做到的是 Error! Reference source not found.A.把二进制代码传送到任何关系数据库中 Error! Reference source not found.B.把 Java 源代码传送到任何关系数据库中 Error! Reference source not found.C.把表单信息传送到任何关系数据库中 Error! Reference source not found.D.很容易地把 SQL 语句传送到任何关系数据库中 3: 1. String s=”Example String”;Which operation is not legal? Error! Reference source not found.A.int i=s.length(); Error! Reference source not found.B.s3=”x”; Error! Reference source not found.C.String short_s=s.trim(); Error! Reference source not found.D.String t=”root”+s; 4: 1. public class X 2. 3. public Object m() 4. 5. Object o = new Float(3.14F);/line 3 6. 7. Object oa = new Object1;/line 4 8. 9. oa0 = o;/line 5 10. 11. o=null;/line 6 12. 13. return oa0;/line 7 14. 15. 16. 17. 18.When is the Float object, created in line 3,eligible for garbage collection? Error! Reference source not found.A.just after line 5. Error! Reference source not found.B.just after line 6 Error! Reference source not found.C.just after line 7(that is,as the method returns) Error! Reference source not found.D.never in this method 5:Which fragments are not correct in Java source file? Error! Reference source not found.A.package testpackage; public class Test/do something. Error! Reference source not found.B.import java.io.*; package testpackage; public class Test/ do something. Error! Reference source not found.C.import java.io.*; class Person/ do something. public class Test/ do something. Error! Reference source not found.D.import java.io.*; import java.awt.*; public class Test/ do something. 6:在下述选项时,没有构成死循环的程序是 Error! Reference source not found.A.int i=100 while (1) i=i%100+1; if (i100) break; Error! Reference source not found.B.for (;); Error! Reference source not found.C.int k=1000; do +k; while(k=10000); Error! Reference source not found.D.int s=36; while (s);-s; 7:Which is the main() method return of a application? Error! Reference source not found.A.String Error! Reference source not found.B.byte Error! Reference source not found.C.char Error! Reference source not found.D.void 8:Use the operator “” and “”. Which statement is true? Error! Reference source not found.A.1010 0000 0000 0000 0000 0000 0000 0000 4 give 0000 1010 0000 0000 0000 0000 0000 0000 Error! Reference source not found.B.1010 0000 0000 0000 0000 0000 0000 0000 4 give 1111 1010 0000 0000 0000 0000 0000 0000 Error! Reference source not found.C.1010 0000 0000 0000 0000 0000 0000 0000 4 give 0000 0000 0000 0000 0000 0000 0000 0000 Error! Reference source not found.D.1010 0000 0000 0000 0000 0000 0000 0000 4 give 1111 1010 0000 0000 0000 0000 0000 0000 9: 1. What will happen when you attempt to compile and run the following code? 2. 3. (Assume that the code is compiled and run with assertions enabled.) 4. 5. public class AssertTest 6. 7. public void methodA(int i) 8. 9. assert i = 0 : methodB(); 10. 11.System.out.println(i); 12. 13. 14. 15.public void methodB() 16. 17.System.out.println(The value must not be negative); 18. 19. 20. 21.public static void main(String args) 22. 23.AssertTest test = new AssertTest(); 24. 25.test.methodA(-10); 26. 27.28. 29. 30. Error! Reference source not found.A.it will print -10 Error! Reference source not found.B.it will result in AssertionError showing the message-“the value must not be negative”. Error! Reference source not found.C.the code will not compile. Error! Reference source not found.D.None of these. 10: 1. The following code is entire contents of a file called Example.java,causes precisely one error during compilation: 2. class SubClass extends BaseClass 3. 4. class BaseClass() 5. String str; 6. public BaseClass() 7. System.out.println(“ok”); 8. public BaseClass(String s) 9. str=s; 10. public class Example 1
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号