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();
}
}
以下哪两项是正确的?()
第1题:
下列变量定义不合法的是( )。
A、boolean flag=false;
B、int k=1+'k';
C、char ch="c";
D、float r=1/2;
第2题:
以下变量初始化语句中,正确的有 ()
A.boolean flag = true;
B.int i = 32;
C.float r = 10.0;
D.double pi = 3.1415926;
E.int value = 32.0;
第3题:
以下语句正确的是()
A.byte b = 128;
B.boolean flag = null;
C.long a = 2147483648L;
D.float f = 0.9239;
第4题:
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);
第5题:
以下赋值语句正确的是()。
A.int a=081;
B.boolean flag=1;
C.float x=3.5;
D.char m=65;