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;