At which line in the following code is the Vector object, created in line 4, first subject to garbage collection?
1. import java.util.*; 2. public class Main { 3. public static void main(String[] args) { 4. Vector v1 = new Vector(); 5. Vector v2 = new Vector(); 6. v1 = null; //from w w w . j a va2 s.co m 7. Vector v3 = v1; 8. v1 = v2; 9. v1.add("This"); 10. v1.add(v2); 11. String s = (String) v1.elementAt(0); 12. v1 = v2; 13. v2 = v1; 14. v1.add(s); 15. } }
A.
In line 6, the null value is assigned to the v1 variable.
This causes the object created in line 4 to become unreachable.