Wrong answer in Mock test 804 - latest version

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
toandang
Posts: 1
Joined: Thu Jun 16, 2016 10:56 am
Contact:

Wrong answer in Mock test 804 - latest version

Post by toandang »

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.

admin
Site Admin
Posts: 10043
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Wrong answer in Mock test 804 - latest version

Post by admin »

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.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests