This was the question I found in Jhon hunt's mock exam?
Q. 31
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
Select
Answer is Line 7
Can anybody explain how?
Thanks
Veena