I saw this question in a mock exam. Can anyone explain how to arrive at the answer?
public class
Test {
private int a;
private int b;
private synchronized void A(int c) {a=c;}
private synchronized void B(int c) {b=c;}
public void AB(int c) {A(c); B(c);}
public synchronized boolean d() {return a != b;}
}
Under which condition will d return true when called from a different class?
A. d can never return true when multiple threads call A and B separately
B. d can never return true only if Test is changed to allow a and b to be set separately
C. d can never return true when AB is called by multiple threads
D. d can never return true