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

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

publicclassTestFive{privateintx;publicvoidfoo(){intcurrent=x;x=current+1;}publicvoidgo(){for(inti=0;i<5;i++){newThread(){publicvoidrun(){foo();System.out.print(x+,);}}.start();}}}Whichtwochanges,takentogether,wouldguaranteetheoutput:1,2,3,4,5,?()

A.Movetheline12printstatementintothefoo()method.

B.Changeline7topublicsynchronizedvoidgo(){.

C.Changethevariabledeclarationonline3toprivatevolatileintx;.

D.Wrapthecodeinsidethefoo()methodwithasynchronized(this)block.

E.Wraptheforloopcodeinsidethego()methodwithasynchronizedblocksynchronized(this){//forloopcodehere}.


参考答案

更多 “ publicclassTestFive{privateintx;publicvoidfoo(){intcurrent=x;x=current+1;}publicvoidgo(){for(inti=0;i5;i++){newThread(){publicvoidrun(){foo();System.out.print(x+,);}}.start();}}}Whichtwochanges,takentogether,wouldguaranteetheoutput:1,2,3,4,5,?()A.Movetheline12printstatementintothefoo()method.B.Changeline7topublicsynchronizedvoidgo(){.C.Changethevariabledeclarationonline3toprivatevolatileintx;.D.Wrapthecodeinsidethefoo()methodwithasynchronized(this)block.E.Wraptheforloopcodeinsidethego()methodwithasynchronizedblocksynchronized(this){//forloopcodehere}. ” 相关考题
考题 publicclassTestSevenextendsThread{privatestaticintx;publicsynchronizedvoiddoThings(){intcurrent=x;current++;x=current;}publicvoidrun(){doThings();}}Whichistrue?() A.Compilationfails.B.Anexceptionisthrownatruntime.C.Synchronizingtherun()methodwouldmaketheclassthread-safe.D.Thedatainvariable“x”areprotectedfromconcurrentaccessproblems.E.DeclaringthedoThings()methodasstaticwouldmaketheclassthread-safe.F.WrappingthestatementswithindoThings()inasynchronized(newObject()){}blockwouldmaketheclassthread-safe.

考题 publicclassStarterextendsThread{privateintx=2;publicstaticvoidmain(String[]args)throwsException{newStarter().makeItSo();}publicStarter(){x=5;start();}publicvoidmakeItSo()throwsException{join();x=x-1;System.out.println(x);}publicvoidrun(){x*=2;}}Whatistheoutputifthemain()methodisrum?()A.4B.5C.8D.9E.Compilationfails.F.Anexceptionisthrownatruntime.G.Itisimpossibletodetermineforcertain.

考题 publicabstractclassShape{privateintx;privateinty;publicabstractvoiddraw();publicvoidsetAnchor(intx,inty){this.x=x;this.y=y;}}WhichtwoclassesusetheShapeclasscorrectly?() A.publicclassCircleimplementsShape{privateintradius;}B.publicabstractclassCircleextendsShape{privateintradius;}C.publicclassCircleextendsShape{privateintradius;publicvoiddraw();}D.publicabstractclassCircleimplementsShape{privateintradius;publicvoiddraw();}E.publicclassCircleextendsShape{privateintradius;publicvoiddraw(){/*codehere*/}}F.publicabstractclassCircleimplementsShape{privateintradius;publicvoiddraw(){/codehere*/}}

考题 A.f(-x,y)=f(x,y),f(x,-y)=-f(x,y) B.f(-x,y)=f(x,y),f(x,-y)=f(x,y) C.f(-x,y)=-f(x,y),f(x,-y)=-f(x,y) D.f(-x,y)=-f(x,y),f(x,-y)=f(x,y)

考题 若f(-x)=f(x),且在(0,+∞)内f′(x)>0,f″(x)<0,则f(x)在(-∞,0)内( )。A.f′(x)<0,f″(x)<0 B.f′(x)<0,f″(x)>0 C.f′(x)>0,f″(x)<0 D.f′(x)>0,f″(x)>0

考题 若f(-x)=f(x),且在(0,+∞)内f′(x)>0,f″(x)<0,则f(x)在(-∞,0)内( )。《》( )A.f′(x)<0,f″(x)<0 B.f′(x)<0,f″(x)>0 C.f′(x)>0,f″(x)<0 D.f′(x)>0,f″(x)>0

考题 若f(x)=-f(-x),在(0,+∞)内f′(x)>0,f″(x)>0,则在(-∞,0)内( )《》( )A.f′(x)<f″(x)<0 B.f′(x)<f″(x)>0 C.f′(x)>f″(x)<0 D.f′(x)>f″(x)>0

考题 若f(x)、F(x)分别为随机变量X的密度函数、分布函数,则( )。A.F(x)=f(x) B.F(x)≥f(x) C.F(x)≤f(x) D.f(x)=-F'(x)

考题 下列关于整除的命题中,正确的是______。A.若f(x)|g(x)+h(x),则f(x)|g(x)或f(x)|h(x)B.若f(x)|g(x)+h(x),且f(x)|g(x),则f(x)|h(x)C.若f(x)|g(x)h(x),则f(x)|g(x)或f(x)|h(x)D.若f(x)|g(x)h(x),且f(x)不整除g(x),则f(x)|h(x)