Hi All,
Following is the question from JQPlus
Question ID :988383539812
Consider the following code:
public class
Test extends
Thread {
static int x, y;
public synchronized void setX(int i) { x++; }
public synchronized void setY(int j) {y++; }
public void setXY(int i, int j) { setX(i); setY(j); }
public boolean testXY() { return x != y;}
public void run(){ setXY(); System.out.println(testXY()); } //line1
public static void main(
String[] args)
{
new Test().start();
new Test().start();
}
}
The above code will always print "false".
The anwser given is false means it will always prints TRUE.
But the above program will fail to compile because at line 1 method setXY() is called with no arguments and there is no such method.
Also if you call method with (1,1) or (1,2) it will always prints false.
I think this is a wrong question.
Paul please correct me if I am wrong.
Thanks,
Avinash