Question 765: public class X { public static void main(String [] args) { X x = new X(); X x2 = m1(x); /* Line 6 */ X x4 = new X(); x2 = x4; /* Line 8 */ doComplexStuff(); } static X m1(X mx) { mx = new X(); return mx; } }After line 8 runs. how many objects are eligible for garbage collection?
tcs
wipro
infosys
general
aptitude
garbage-collections
java-programming
By the time line 8 has run, the only object without a reference is the one generated as a result of line 6. Remember that "Java is pass by value," so the reference variablexis not affected by them1()method.Ref: http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html