Multiple choice technology programming languages

Given: 1. class Eco { 2. public static void main(String[] args) { 3. Eco e1 = new Eco(); 4. Eco e2 = new Eco(); 5. Eco e3 = new Eco(); 6. e3.e = e2; 7. e1.e = e3; 8. e2 = null; 9. e3 = null; 10. e2.e = el; 11. e1 = null; 12. } 13. Eco e; 14. } At what point is only a single object eligible for GC?

  1. After line 8 runs.

  2. After line 9 runs.

  3. After line 10 runs.

  4. After line 11 runs.

  5. Compilation fails.

  6. An exception is thrown at runtime.

Reveal answer Fill a bubble to check yourself
F Correct answer
Explanation

Line 10 attempts 'e2.e = el' but 'el' is undefined (typo for 'e1'). Since e2 was set to null on line 8, this would cause a NullPointerException. The GC eligibility questions become moot because the code throws an exception before completing.