public class NamedCounter { private final String name; private int count; public NamedCounter(String name) { this.name = name; } public String getName() { return name; } public void increment() { coount++; } public int getCount() { return count; } public void reset() { count = 0; } } Which three changes should be made to adapt this class to be used safely by multiple threads? ()A、 declare reset() using the synchronized keywordB、 declare getName() using the synchronized keywordC、 declare getCount() using the synchronized keywordD、 declare the constructor using the synchronized keywordE、 declare increment() using the synchronized keyword
public class NamedCounter { private final String name; private int count; public NamedCounter(String name) { this.name = name; } public String getName() { return name; } public void increment() { coount++; } public int getCount() { return count; } public void reset() { count = 0; } } Which three changes should be made to adapt this class to be used safely by multiple threads? ()
- A、 declare reset() using the synchronized keyword
- B、 declare getName() using the synchronized keyword
- C、 declare getCount() using the synchronized keyword
- D、 declare the constructor using the synchronized keyword
- E、 declare increment() using the synchronized keyword
相关考题:
public class TestA{ public void methodA() throws IOException{ //…… } } public class TestB extends TestA{ public void methodA() throws EOFException{ //…… } } public class TestC extends TestA{ public void methodA() throws Exception{ //…… } } 当编译类TestC的时候,结果是哪项?() A、 正常B、 编译错误C、 运行错误D、 以上都不对
Given the command line java Pass2 and: public class Pass2 { public void main(String [] args) { int x=6; Pass2 p = new Pass2(); p.doStuff(x); System.out.print(” main x = “+ x); } void doStuff(int x) { System.out.print(” doStuffx = “+ x++); } } What is the result?() A、 Compilation fails.B、 An exception is thrown at runtime.C、 doStuffx = 6 main x = 6D、 doStuffx = 6 main x = 7E、 doStuffx = 7 main x = 6F、 doStuffx = 7 main x = 7
如何设置缺省按钮?()A、调用跟窗格的setdefaultbutton函数设置缺省按钮;B、调用跟窗格的getcontentpane函数获得内容窗格;C、调用内容窗格的setdefaultbutton函数设置缺省按钮;D、调用框架对象的getrootpane函数获得根窗格;E、调用框架对象的setdefaultbutton函数设置缺省按钮;
Given this fragment from a Java EE deployment descriptor: 124. beta.html 125. alpha.html And this request from a browser:http://www.sun.com/SCWCDtestApp/register Which statement is correct,when the container receives this request?()A、This deployment descriptor is NOT valid.B、The container first looks in the register directory for beta.html.C、The container first looks in the register directory for alpha.html.D、The container first looks for a servlet mapping in the deployment descriptor.
在所有的Java系统类中,Object类有什么特殊之处?它在什么情况下使用?