Hi,
source :
http://www.jchq.net/ At which point will the
word "Harpic" be printed out when this code is executed?
class Harpic
{
public void finalize()
{
System.out.println("Harpic");
}
}
public class ArmitageShanks {
Harpic har;
public static void main(String...strings)
{
ArmitageShanks ar = new ArmitageShanks();
}
public void oui()
{
har = new Harpic();
mno(har);
//one
har = null;
}
public void mno(Harpic har)
{
Harpic pic = har;
//two
pic = null;
//three
har = null;
}
}
a)After executing the line after the comment //one
b)After executing the line after the comment //two
c)After executing the line after the comment //three
d)It is impossible to say,
String "Harpic" may not be output at all
For the above i marked c) as the answer. But they have given d) .
can any one explain it?
Is this type of questions come in real exam?
rami