public class Test extends Thread {
static int x, y;
public static synchronized void setX(int i) {
x++;
}
public static 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(1, 2);
System.out.println(testXY());
}
public static void main(String[] args) {
new Test().start();
new Test().start();
}
}
The above code will always print
false
false
select 1 option:
True
False
I have tested the class, it always return false/false, correct answer is True, but the answer is false.
Wrong answer in Mock test 804 - latest version
Moderator: admin
-
- Posts: 1
- Joined: Thu Jun 16, 2016 10:56 am
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: Wrong answer in Mock test 804 - latest version
Did you read the explanation given with the question?
Also, please include the question id in the subject so that we can track the question. I believe you are talking about question 2.1341, right?
-Paul.
Also, please include the question id in the subject so that we can track the question. I believe you are talking about question 2.1341, right?
-Paul.
Who is online
Users browsing this forum: No registered users and 17 guests