In the following code, which is the earliest statement, where the object originally held in e, may be garbage collected:
public class
Test {
public static void main (
String args []) {
Employee e = new Employee("Bob", 48);
e.calculatePay();
System.out.println(e.printDetails());
e = null;
e = new Employee("Denise", 36);
e.calculatePay();
System.out.println(e.printDetails());
}
}
Line 10
Line 11
Line 7
Line 8
Never
Answer is line7 but I don't understand why? Can somebody explain me?
Thanks,
Ash