11. public void genNumbers() {  12. ArrayList numbers = new 

题目
单选题
11. public void genNumbers() {  12. ArrayList numbers = new ArrayList();  13. for (int i=0; i<10; i++) {  14. int value = i * ((int) Math.random());  15. Integer intObj = new Integer(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 garbage collection?()
A

 Line 16

B

 Line 17

C

 Line 18

D

 Line 19

E

 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?() 

  • A、 StackOverflowError
  • B、 NullPointerException
  • C、 NumberFormatException
  • D、 IllegalArgumentException
  • E、 ExceptionlnlnitializerError

正确答案:A

第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?() 

  • A、 B
  • B、 The code runs with no output.
  • C、 Compilation fails because of an error in line 12.
  • D、 Compilation fails because of an error in line 15.
  • E、 Compilation fails because of an error in line 18.

正确答案:A

第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.


参考答案:D

第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?() 

  • A、 assert value == null;
  • B、 assert value !null, “value is null”;
  • C、 if (value == null) { throw new AssertionException(”value is null”);
  • D、 if (value == null) { throw new IllegalArgumentException(”value is null”);

正确答案:D

第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?()  

  • A、 Line 13
  • B、 Line 14
  • C、 Line 18
  • D、 Line 20

正确答案:D

第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?() 

  • A、 go in Goban     go in Sente go in Sente
  • B、 go in Sente      go in Sente go in Goban
  • C、 go in Sente     go in Goban go in Goban
  • D、 go in Goban    go in Goban go in Sente
  • E、 Compilation fails because of an error in line 17.

正确答案:C

第7题:

Which two code fragments will execute the method doStuff() in a separate thread?()

  • A、 new Thread() { public void run() { doStuff(); } }
  • B、 new Thread() { public void start() { doStuff(); } }
  • C、 new Thread() { public void start() { doStuff(); } } .run();
  • D、 new Thread() { public void run() { doStuff(); } } .start();
  • E、 new Thread(new Runnable() { public void run() { doStuff(); } } ).run();
  • F、 new Thread(new Runnable() { public void run() { doStuff(); } }).start();

正确答案:D,F

第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?()

  • A、Line16
  • B、Line17
  • C、Line18
  • D、Line19
  • E、The object is NOT a candidate for garbage collection.

正确答案:D

第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.”?() 

  • A、 p.setWeight(420);
  • B、 p.changePayload(420);
  • C、 p = new Payload(420);
  • D、 Payload.setWeight(420);
  • E、 p = Payload.setWeight(420);
  • F、 p = new Payload(); p.setWeight(420);

正确答案:A

第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行,哪三行允许代码编译?()    

  • A、 Map c= new SortedMap();
  • B、 HashMap c= new HashMap();
  • C、 HashMap c= new Hashtalole();
  • D、 SortedMap c= new TreeMap();
  • E、 ArrayList c= new ArrayList();
  • F、  MaD c = new LinkedHashMap();

正确答案:B,D,F

更多相关问题