单项选择题
1.public class GC{
2.private Objec to;
3.private void doSomethingElse(Object obj){o=obj;}
4.public void doSomething(){
5.Object o=new Object();
6.doSomethingElse(o);
7.o=new Object();
8.doSomethingElse(null);
9.o=null;
10.}
11.}
When the doSomething method is called,after which line does the Object created in line 5 become available for garbage collection?()
A.Line5
B.Line6
C.Line7
D.Line8
E.Line9
F.Line10
相关考题
-
单项选择题
11.class Snoochy{ 12.Boochybooch; 13.public Snoochy(){booch=newBoochy(this);} 14.} 15. 16.class Boochy{ 17.Snoochy snooch; 18.public Boochy(Snoochys){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. -
单项选择题
11.rbo = new ReallyBigObject(); 12.//more code here 13.rbo = null; 14./*insert code here*/ Which statement should be placed at line 14 to suggest that the virtual machine expend effort toward recycling the memory used by the objectrbo?()
A.System.gc();
B.Runtime.gc();
C.System.freeMemory();
D.Runtime.getRuntime().growHeap();
E.Runtime.getRuntime().freeMemory(); -
单项选择题
package test; class Target{ public String name="hello"; } What can directly access and change the value of the variable name?()
A.any class
B.only the Target class
C.any class in the test package
D.any class that extends Target
