John Hunt mock
test Question 31
In the following code which is the earliest statement, where the object originally held in employee, 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());
}
}
A. Line 10
B. Line 11
C. Line 7
D. Line 8
E. Never
The answer is 'C'
Can anyone explain why?
Thanks!