The Growth Model is more popular with Third World scholars than Western scholars.
A.YES
B.NO
C.NOT GIVEN
第1题
A.Movetheline12printstatementintothefoo()method.
B.Changeline7topublicsynchronizedvoidgo(){.
C.Changethevariabledeclarationonline3toprivatevolatileintx;.
D.Wrapthecodeinsidethefoo()methodwithasynchronized(this)block.
E.Wraptheforloopcodeinsidethego()methodwithasynchronizedblocksynchronized(this){//forloopcodehere}.
第2题
publicclassNameList{
privateListnames=newArrayList();
publicsynchronizedvoidadd(Stringname){names.add(name);}
publicsynchronizedvoidprintAll(){
for(inti=0;iSystem.out.print(names.get(i)+);
}
}
publicstaticvoidmain(String[]args){
finalNameListsl=newNameList();
for(inti=0;i<2;i++){
newThread(){
publicvoidruin(){
sl.add(”A”);
sl.add(”B”);
sl.add(”C”);
sl.printAll();
}
}.start();
}
}
}
Whichtwostatementsaretrueifthisclassiscompiledandrun?()
第3题
A.0,2,4,4,6,8,10,6,
B.0,2,4,6,8,10,2,4,
C.0,2,4,6,8,10,12,14,
D.0,0,2,2,4,4,6,6,8,8,10,10,12,12,14,14,
E.0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14,
第4题
A.declarereset()usingthesynchronizedkeyword
B.declaregetName()usingthesynchronizedkeyword
C.declaregetCount()usingthesynchronizedkeyword
D.declaretheconstructorusingthesynchronizedkeyword
E.declareincrement()usingthesynchronizedkeyword
第5题
privatestaticObjectresource=newObject();
privatestaticvoiddelay(longn){
try{Thread.sleep(n);}
catch(Exceptione){System.out.print(”Error);}
}
publicstaticvoidmain(String[]args){
System.out.print(”StartMain);
newThread1().start();
delay(1000);
Threadt2=newThread2();
t2.start();
delay(1000);
t2.interrupt
delay(1000);
System.out.print(”EndMain);
}
staticclassThread1extendsThread{
publicvoidrun(){
synchronized(resource){
System.out.print(”Startl);
delay(6000);
System.out.print(”End1);
}
}
}
staticclassThread2extendsThread{
publicvoidrun(){
synchronized(resource){
System.out.print(”Start2);
delay(2000);
System.out.print(”End2);
}
}
}
}
Assumethatsleep(n)executesinexactlymmilliseconds,andallothercodeexecutesinaninsignificantamountoftime.Whatistheoutputifthemain()methodisrun?()
第6题
A.Compilationfails.
B.Anexceptionisthrownatruntime.
C.Thecodeexecutesandprints“StartedComplete”.
D.Thecodeexecutesandprints“StartedComplete0123”.
E.Thecodeexecutesandprints“Started0l23Complete”.
第7题
A.Compilationfails.
B.Anexceptionisthrownatruntime.
C.Thecodeexecutesnormallyandprints“sleep”.
D.Thecodeexecutesnormally,butnothingisprinted.
第8题
A.java.lang.RuntimeException:Problem
B.run. java.lang.RuntimeException:Problem
C.Endofmethod. java.lang.RuntimeException:Problem
D.Endofmethod. run.java.lang.RuntimeException:Problem
E.run. java.lang.RuntimeException:ProblemEndofmethod.
第9题
A.4
B.5
C.8
D.9
E.Compilationfails.
F.Anexceptionisthrownatruntime.
G.Itisimpossibletodetermineforcertain.
第10题
A.Cat
B.Dog
C.Compilationfails.
D.Thecoderunswithnooutput.
E.Anexceptionisthrownatruntime.
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!