Line 16
Line 17
Line 18
Line 19
The object is NOT a candidate for garbage collection.
第1题:
10. public class ClassA { 11. public void count(int i) { 12. count(++i); 13. } 14. } And: 20. ClassA a = new ClassA(); 21. a.count(3); Which exception or error should be thrown by the virtual machine?()
第2题:
11. static class A { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println(”B”); } 16. } 17. public static void main(String[] args) { 18. new B().process(); 19. } What is the result?()
第3题:
11.public void genNumbers(){12.ArrayList numbers=new ArrayList();13.for(inti=0;i14.intvalue=i*((int)Math.random());15.IntegerintObj=newInteger(value);16.numbers.add(intObj);17.}18.System.out.println(numbers);19.}Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbagec ollection?()
A.Line16
B.Line17
C.Line18
D.Line19
E.The object is NOT a candidate for garbage collection.
第4题:
11. public void someMethod(Object value) { 12. // check for null value .... 20. System.out.println(value.getClass()); 21. } What, inserted at line 12, is the appropriate way to handle a null value?()
第5题:
11. public class Test { 12. public void foo() { 13. assert false; 14. assert false; 15. } 16. public void bar(){ 17. while(true){ 18. assert false; 19. } 20. assert false; 21. } 22. } What causes compilation to fail?()
第6题:
1. public class GoTest { 2. public static void main(String[] args) { 3. Sente a = new Sente(); a.go(); 4. Goban b = new Goban(); b.go(); 5. Stone c = new Stone(); c.go(); 6. } 7. } 8. 9. class Sente implements Go { 10. public void go() { System.out.println(”go in Sente.”); } 11. } 12. 13. class Goban extends Sente { 14. public void go() { System.out.println(”go in Goban”); } 15. } 16. 17. class Stone extends Goban implements Go { } 18. 19. interface Go { public void go(); } What is the result?()
第7题:
Which two code fragments will execute the method doStuff() in a separate thread?()
第8题:
11.public void genNumbers(){ 12.ArrayList numbers=new ArrayList(); 13.for(inti=0;i<10;i++){ 14.intvalue=i*((int)Math.random()); 15.IntegerintObj=newInteger(value); 16.numbers.add(intObj); 17.} 18.System.out.println(numbers); 19.} Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbagec ollection?()
第9题:
11. class Payload { 12. private int weight; 13. public Payload(int wt) { weight = wt; } 13. public void setWeight(mt w) { weight = w; } 15. public String toString { return Integer.toString(weight); } 16. } 17. 18. public class TestPayload { 19. static void changePayload(Payload p) { 20. /* insert code here */ 21. } 22. 23. public static void main(String[] args) { 24. Payload p = new Payload(); 25. p.setWeight(1024); 26. changePayload(p); 27. System.out.println(”The value of p is “+ p); 28. } 29. } Which statement, placed at line 20, causes the code to print “The value of p is 420.”?()
第10题:
现有: 1. import java.util.*; 2. 3. Class FindStuff { 4.public static void main (String[]args) { 5, //insert code here 6. c.put ("X", 123); 7. } 8. } 分别插入到第5行,哪三行允许代码编译?()