Given the following code:
class MyClass { } class Main { //from ww w . j a v a 2 s . co m private MyClass m = new MyClass (); public void m (MyClass pMyClass){ pMyClass = null; } public void m2 (){ m (m); } public static void main (String [] args){ Main n = new Main (); n.m2 (); } }
Which of the following statements are correct?
Select 1 option
pMyClass
= null; in m (), marks the private instance of MyClass for garbage collection. Correct Option is : A
An object can be made eligible for garbage collection by making sure there are no references pointing to that object.
You cannot directly invoke the garbage collector.
You can suggest the JVM to perform garbage collection by calling System.gc()
;