HI all,
This is from Boone's Mock Exam.
Can someone plz clarify that how the first is eligible for GC at label d.I feel args[0] is still referenced by riddle.
Which label identifies the earliest point where, after that line has executed, the object referred to by the variable first may be garbage collected?
class Riddle {
public static void main(
String[] args) {
String first, second;
String riddle;
if (args.length < 2)
return; a: first = new String(args[0]);
b: second = new String(args[1]);
c: riddle = "When is a " + first;
d: first = null;
e: riddle += " like a " + second + "?";
f: second = null;
g: System.out.println(riddle);
h: args[0] = null;
i: args[1] = null;
j:
}
}
options are
a)d:
b)e:
c)h:
d)i:
e)j:
OH! these GC always when I think I mastered them I goof up!!!
Thanx in advance.
Rajani