可学答题网 > 问答 > SCJP程序员认证考试题库
目录: 标题| 题干| 答案| 搜索| 相关
问题

public class SyncTest 


public class SyncTest {  private int x;  private int y;  public synchronized void setX (int i) (x=1;)  public synchronized void setY (int i) (y=1;)  public synchronized void setXY(int 1)(set X(i); setY(i);)  public synchronized Boolean check() (return x !=y;)  }  Under which conditions will check () return true when called from a different class?

  • A Check() can never return true.
  • B Check() can return true when setXY is called by multiple threads.
  • C Check() can return true when multiple threads call setX and setY separately.
  • D Check() can only return true if SyncTest is changed to allow x and y to be set separately.
参考答案
参考解析:
分类:SCJP程序员认证考试题库
相关推荐

1、10. public class Class

10. public class ClassA { 11. public void methodA() { 12. ClassB classB = new ClassB()...

2、public class SyncTest 

public class SyncTest { private int x; private int y; private synchronized void setX( int&en...

3、public class X { 

public class X { public static void main(String [] args) { try { badMethod(); System.out.p...

4、10. public class Class

10. public class ClassA { 11. public void count(int i) { 12. count(++i); 13. } 14.&en...

5、public class SyncTest 

public class SyncTest ( private int x; private int y; private synchronized void setX (int&e...

6、public class SyncTest 

public class SyncTest (  private int x;  private int y;  private synchronized void&ensp...