单项选择题

11. class Snoochy { 
12. Boochybooch; 
13. public Snoochy() { booch = new Boochy(this); } 
14. } 
15. 
16. class Boochy { 
17. Snoochy snooch; 
18. public Boochy(Snoochy s) { snooch = s; } 
19. } 
And the statements: 
21. public static void main(String[] args) { 
22. Snoochy snoog = new Snoochy(); 
23. snoog = null; 
24. // more code here 
25. } 
Which statement is true about the objects referenced by snoog, snooch, and booch immediately after line 23 executes?() 

A. None of these objects are eligible for garbage collection.
B. Only the object referenced by booch is eligible for garbage collection.
C. Only the object referenced by snoog is eligible for garbage collection.
D. Only the object referenced by snooch is eligible for garbage collection.
E. The objects referenced by snooch and booch are eligible for garbage collection.


您可能感兴趣的试卷

你可能感兴趣的试题

5.单项选择题

public class ItemTest { 
private final mt id; 
public ItemTest(int id) { this.id = id; } 
public void updateId(int newId) { id = newId; } 
public static void main(String[] args) { 
ItemTest fa = new ItemTest(42); 
fa.updateId(69); 
System.out.println(fa.id); 
} 
} 
What is the result?() 

A. Compilation fails.
B. An exception is thrown at runtime.
C. The attribute id in the Item object remains unchanged.
D. The attribute id in the Item object is modified to the new value.
E. A new Item object is created with the preferred value in the id attribute.

8.多项选择题

11. public class Commander { 
12. public static void main(String[] args) { 
13. String myProp = /* insert code here */ 
14. System.out.println(myProp); 
15. } 
16. } 
and the command line: 
java -Dprop.custom=gobstopper Commander 
Which two, placed on line 13, will produce the output gobstopper?()

A. System.load(”prop.custom”);
B. System.getenv(”prop.custom”);
C. System.property(”prop.custom”);
D. System.getProperty(”prop.custom”);
E. System.getProperties().getProperty(”prop.custom”);

10.单项选择题

public class Yippee { 
public static void main(String [] args) { 
for(int x = 1; x < args.length; x++) { 
System.out.print(args[x] +“ “); 
} 
} 
} 
and two separate command line invocations: 
java Yippee 
java Yippee 1234 
What is the result?() 

A. No output is produced. 123
B. No output is produced. 234
C. No output is produced. 1234
D. An exception is thrown at runtime. 123
E. An exception is thrown at runtime. 234
F. An exception is thrown at rijntime. 1234