Given:
2. public class Main { 3. static Main st; 4. public static void main(String[] args) { 5. new Main().go(); 6. // what's eligible? 7. } //from w ww .jav a 2s.co m 8. void go() { 9. MyInner in = new MyInner(); 10. Integer i3 = in.doInner(); 11. Main t = new Main(); 12. st = t; 13. System.out.println(i3); 14. } 15. class MyInner { 16. public Integer doInner() { return new Integer(34); } 17. } 18. }
When the code reaches line 6, which are eligible for garbage collection? (Choose all that apply.)
D, E, and F are correct.
A, B, and C are incorrect because only objects are considered by the GC.
G is incorrect because main()
could still access line 11's Main object through st.