单项选择题
在堆栈类Sharedstack的定义中,为了保证堆栈在并发操作中数据的正确性,应在下画线处填入的修饰符是(两个下画线的填写内容相同)( )。
public class SharedStack
______int idx=0;
char[]data=new chaf[10];
public synchtonized void push(char c)......)
public synchronized void pop()......)
A.public
B.不使用修饰符
C.private
D.protected
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
关于下列代码编译或执行结果的描述中,正确的是( )。 public class Test public static void main(String args[]) TestThread pm1=new TestThread( One ) pm1.start(); TestThread pm2=new TestThread( Two ) pm2.start(); class TestTbread extends Thread( private String sTname= ; TestThread(String s) sTname=s; public void run() for(int i=0;i<2;i++) try sleep(1000); catch(InterruptedException e) system.out.print(sTname+ );
A.不能通过编译,TestThread类中不能定义变量和构造方法
B.输出One One Two Two
C.输出Two One One Two
D.选项B或C都有可能出现
点击查看答案&解析
单项选择题
下列代码的执行结果是( )。 public class Test public static void main(String[]args) int[]x=0,1,2,3; forint i=0;i<3;1+=2) try system.out.println(x[i+2] x[i]+x[i+1]); catch(ArithmeticException e) System.out.println( error1 ); catch(Exception e) System.out.println( error2 );
A.error1
B.error2
C.error1
orror2
D.2
error2
点击查看答案&解析
相关试题
Java的线程调度策略是一种基于优先级的__...
下列代码的功能是把按钮save添加到窗口myFr...
根据下列类声明,可以得知类TwoListeners能...
一个Applet被浏览器加载后,是从_____...
下列代码的执行结果是______。 publ...