当前位置:SCJP程序员认证考试题库

问题:

[多选]

Given the following code, which statements concerning the objects referenced through the member variables i, j and k are true, given that any thread may call the methods a, b and c at any time? () 
class Counter {  int v = 0;  
synchronized void inc() { v++; }  
synchronized void dec() { v--; }  
}  
public class Q7ed5 {  
Counter i;  
Counter j;  
Counter k;  
public synchronized void a() {  
i.inc();  
System.out.println("a");  
i.dec();  }  
public synchronized void b() {  
i.inc(); 
j.inc(); 
k.inc();  
System.out.println("b"); 
i.dec(); 
j.dec();
k.dec();  }  
public void c() {  
k.inc();  
System.out.println("c");  
k.dec();  
}  
}  

A . i.v is guaranteed always to be 0 or 1.
B . j.v is guaranteed always to be 0 or 1.
C . k.v is guaranteed always to be 0 or 1
D . j.v will always be greater than or equal to k.v at any give time.
E . k.v will always be greater than or equal to j.v at any give time.

标志世界新闻学走向成熟的两部代表性作品是《新闻学原理》和()。 《报刊的四种理论》。 《德国新闻事业史》。 《舆论学》。 《实用新闻学》。 简述液体粘性的产主。 证据和证据材料有何区别? 百度于2013年2月推出的绿萝算法是针对哪种作弊行为的惩罚机制?() 交换链接。 复制和抄袭内容。 低质量内容。 链接买卖。 ()的重点在于组织成员之间在权力和利益等资源的重新分配。 人员变革。 结构变革。 技术变革。 组织文化变革。

Given the following code, which statements concerning the objects referenced through the member variables i, j and k are true, given that any thread may call the methods a, b and c at any time? () 
class Counter {  int v = 0;  
synchronized void inc() { v++; }  
synchronized void dec() { v--; }  
}  
public class Q7ed5 {  
Counter i;  
Counter j;  
Counter k;  
public synchronized void a() {  
i.inc();  
System.out.println("a");  
i.dec();  }  
public synchronized void b() {  
i.inc(); 
j.inc(); 
k.inc();  
System.out.println("b"); 
i.dec(); 
j.dec();
k.dec();  }  
public void c() {  
k.inc();  
System.out.println("c");  
k.dec();  
}  
}  

参考答案:

  参考解析

本题暂无解析

在线 客服