网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

classWaitingimplementsRunnable{

booleanflag=false;

publicsynchronizedvoidrun(){

if(flag){

flag=false;

System.out.print("1");

try{this.wait();}catch(Exceptione){}

System.out.print("2");

}

else{

flag=true;

System.out.print("3");

try{Thread.sleep(2000);}catch(Exceptione){}

System.out.print("4");

notify();

}

}

publicstaticvoidmain(String[]args){

Waitingw=newWaiting();

newThread(w).start();

newThread(w).start();

}

}

以下哪两项是正确的?()


参考答案

更多 “ classWaitingimplementsRunnable{booleanflag=false;publicsynchronizedvoidrun(){if(flag){flag=false;System.out.print(1);try{this.wait();}catch(Exceptione){}System.out.print(2);}else{flag=true;System.out.print(3);try{Thread.sleep(2000);}catch(Exceptione){}System.out.print(4);notify();}}publicstaticvoidmain(String[]args){Waitingw=newWaiting();newThread(w).start();newThread(w).start();}}以下哪两项是正确的?() ” 相关考题
考题 下列变量定义合法的是()。 A.intk=1+kB.floatr=1/2C.charch=“c“D.booleanflag=false

考题 现有:classWaitingimplementsRunnable{booleanflag=false;publicsynchronizedvoidrun(){if(flag){flag=false;System.out.print(1);try{this.wait();)catch(Exceptione){}System.out.print(2);}else{flag=true;System.out.print(3);try{Thread.sleep(2000);}catch(Exceptione){}System.out.print(4);notify();}}publicstaticvoidmain(String[]args){Waitingw=newWaiting();newThread(w).start();newThread(w).start();}}以下哪两项是正确的?()

考题 Whichstatementsconcerningtherelationshipsbetweenthefollowingclassesaretrue?()classFoo{intnum;Bazcomp=newBaz();}classBar{booleanflag;}classBazextendsFoo{Barthing=newBar();doublelimit;} A.ABarisaBaz.B.AFoohasaBar.C.ABazisaFoo.D.AFooisaBaz.E.ABazhasaBar.

考题 publicclassAlpha1{publicstaticvoidmain(String[]args){booleanflag;inti=0;do{flag=false;System.out.println(i++);flag=i10;continue;}while((flag)?true:false);}}Whatistheresult?() A.000000000B.0123456789C.Compilationfails.D.Thecoderunswithnooutput.E.Thecodeentersaninfiniteloop.F.Anexceptionisthrownatruntime.

考题 下列变量定义不合法的是( )。A、boolean flag=false;B、int k=1+'k';C、char ch="c";D、float r=1/2;

考题 下列能够判断Spring容器是否包含ID为proBean的Bean的代码为( )。 A.boolean flag = beanFactory.containsBean("proBean");B.PropertiesBean propertiesBean= (PropertiesBean)beanFactory.getBean("proBean");C.Class classType = beanFactory.getType("proBean");D.PropertiesBean propertiesBean= (PropertiesBean)beanFactory.getBean("proBean", PropertiesBean.class);

考题 以下变量初始化语句中,正确的有 ()A.boolean flag = true;B.int i = 32;C.float r = 10.0;D.double pi = 3.1415926;E.int value = 32.0;

考题 以下赋值语句正确的是()。A.int a=081;B.boolean flag=1;C.float x=3.5;D.char m=65;

考题 以下语句正确的是()A.byte b = 128;B.boolean flag = null;C.long a = 2147483648L;D.float f = 0.9239;