This is the code I came across while seeing earlier posts regarding garbage collection in javaranch forums.
class Riddle
{
public static void main(
String[] args)
{
String first, second;
String riddle;
if (args.length < 2)
return;
first = new String(args[0]);
second = new String(args[1]);
riddle = "When is a " + first;
d:first = null;
riddle += " like a " + second + "?";
e:second = null;
System.out.println(riddle);
h:args[0] = null;
i:args[1] = null;
System.out.println(args[0]);
}
}
Select the one right answer.
1)d:
2)e:
3)h:
4)i:
I think the right answer is [1] that is, after the line d in executed.
Please clarify if I am wrong.
thanks
mrudul
[ December 12, 2003: Message edited by: mrudul joshi ]