1、选择题 1:关于垃圾收集的哪些叙述是对的。 A.程序开发者必须自己创建一个线程进行内存释放的工作。 B.垃圾收集将检查并释放不再使用的内存。 C.垃圾收集允许程序开发者明确指定并立即释放该内存。 D.垃圾收集能够在期望的时间释放被java对象使用的内存。 2: 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.Str
2、ing t=”root”+s; 3:What is written to the standard output given the following statement:System.out.println(4|7); Select the right answer: A.4 B.5 C.6 D.7 4:Which declares for native method in a java class corrected? A.public native void method() B.public native void method(); C.public native method()
3、; D.public void native method(); 5: 1. Whathappenswhenyoutrytocompileandrunthefollowingprogram? 2. classMystery 3. Strings; 4. publicstaticvoidmain(Stringargs) 5. Mysterym=newMystery(); 6. m.go(); 7. 8. voidMystery() 9. s=”constructor”; 10. 11. voidgo() 12. System.out.println(s); 13. 14. What happen
4、s when you try to compile and run the following program?class MysteryString s;public static void main(String args)Mystery m=new Mystery();m.go();void Mystery()s=”constructor”;void go()System.out.println(s);A.this code compliles but throws an exception at runtime B.this code runs but nothing appears
5、in the standard output C.this code runs and “constructor” in the standard output D.this code runs and writes ”null” in the standard output 6:public class Parent int change() class Child extends Parent Which methods can be added into class Child? A.public int change() B.abstract int chang() C.private
6、 int change() D.none 7: 1. Whatwillhappenwhenyouattempttocompileandrunthefollowingcode? 2. 3. publicclassStatic 4. 5. 6. 7. static8. 9. 10. 11. intx=5; 12. 13. 14. 15. staticintx,y; 16. 17. publicstaticvoidmain(Stringargs) 18. 19. 20. 21. x-; 22. 23. myMethod(); 24. 25. System.out.println(x+y+x); 26
7、. 27. 28. 29. publicstaticvoidmyMethod() 30. 31. 32. 33. y=x+x; 34. 35. 36. 37. 38. 39. Choices:What will happen when you attempt to compile and run the following code? public class Staticstaticint x = 5; static int x,y;public static void main(String args) x-; myMethod(); System.out.println(x + y +
8、+x); public static void myMethod()y = x+ + +x; Choices:A.prints : 2 B.prints : 3 C.prints : 7 D.prints : 8 8:A class design requires that a particular member variable must be accessible for direct access by any subclasses of this class. but otherwise not by classes which are not members of the same
9、package. What should be done to achieve this? A.The variable should be marked public B.The variable should be marked private C.The variable should be marked protected D.The variable should have no special access modifier 9: 1. Givethefollowingcode: 2. publicclassExample 3. publicstaticvoidmain(Strin
10、gargs) 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.pr
11、intln(“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 10:假定a和b为int型变量,则执行下述语句组后,b的值为 a=1; b=10; do b-=a; a+; while (b-0); A.9 B.-2 C.-1 D.8 11:Which fragments are not correct in Java source file? A.package testpackage; public cl
12、ass Test/do something. B.import java.io.*; package testpackage; public class Test/ do something. C.import java.io.*; class Person/ do something. public class Test/ do something. D.import java.io.*; import java.awt.*; public class Test/ do something. 12: 1. Givethisclassoutline: 2. classExample 3. pr
13、ivateintx; 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 13:In th
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1