1. class Bar { } 1. class Test { 2. Bar doBar() { 3. Bar b = new Bar(); 4. return b; 5. } 6. public static void main (String args[]) { 7. Test t = new Test(); 8. Bar newBar = t.doBar(); 9. System.out.println(“newBar”); 10. newBar = new Bar(); 11. System.out.println(“finishing”); 12. } 13. } At what point is the Bar object, created on line 3, eligible for garbage collection?()
- A、 After line 8.
- B、 After line 10.
- C、 After line 4, when doBar() completes.
- D、 After line 11, when main() completes.
正确答案:B
答案解析:有
微信扫一扫手机做题