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

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

classOrderimplementsRunnable{publicvoidrun(){try{Thread.sleep(2000);}catch(Exceptione){}System.out.print("in");}publicstaticvoidmain(String[]args){Threadt=newThread(newOrder());t.start();System.out.print("pre");try{t.join();}catch(Exceptione){}System.out.print("post");}}可产生哪两项结果?()

A.inpre

B.prein

C.inprepost

D.preinpost


参考答案

更多 “ classOrderimplementsRunnable{publicvoidrun(){try{Thread.sleep(2000);}catch(Exceptione){}System.out.print(in);}publicstaticvoidmain(String[]args){Threadt=newThread(newOrder());t.start();System.out.print(pre);try{t.join();}catch(Exceptione){}System.out.print(post);}}可产生哪两项结果?()A.inpreB.preinC.inprepostD.preinpost ” 相关考题
考题 classThreadExceptimplementsRunnable{publicvoidrun(){thrownewRuntimeException(exception);}publicstaticvoidmain(String[]args){newThread(newThreadExcept()).start();try{intx=Integer.parseInt(args[0]);Thread.sleep(x);System.out.print(main);}catch(Exceptione){}}}和命令行:javaThreadExcept1000哪一个是结果?()A.mainB.编译失败C.代码运行,但没有输出D.mainjava.lang.RuntimeException:exception

考题 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();}}以下哪两项是正确的?()

考题 5.classOrder2implementsRunnable{6.publicvoidrun(){7.for(intx=0;x〈4;x++){8.try{Thread.sleep(100);}catch(Exceptione){}9.System.out.print(r);10.}}11.publicstaticvoidmain(String[]args){12.Threadt=newThread(newOrder2());13.t.start();14.for(intx=0;x〈4;x++){15.//insertcodehere16.System.out.print(m);17.}}}哪一个插入到第15行,最有可能产生输出rmrmrmrm?()A.Thread.sleep(1);B.Thread.sleep(100);C.Thread.sleep(1000);D.try{Thread.sleep(100);}catch(Exceptione){}

考题 classBirds{publicstaticvoidmain(String[]args){try{thrownewException();}catch(Exceptione){try{thrownewException();}catch(Exceptione2){System.out.print(inner);}System.out.print(middle);}System.out.print(outer);}}结果为:()A.innerB.innerouterC.middleouterD.innermiddleouter

考题 classWorkimplementsRunnable{Threadother;Work(Threadother){this.other=other;}publicvoidrun(){try{other.join();}catch(Exceptione){}System.out.print(afterjoin);}}classLaunch{publicstaticvoidmain(String[]args){newThread(newWork(Thread.currentThread())).start();System.out.print(afterstart);}}结果为:()A.afterjoinB.afterstartC.afterjoinafterstartD.afterstartafterjoin

考题 现有:classThreadExceptimplementsRunnable{publicvoidrun(){thrownewRuntimeException(exception);}publicstaticvoidmain(String[]args){newThread(newThreadExcept()).start();try{intx=Integer.parseInt(args[0]);Thread.sleep(x);System.out.print(main);}catch(Exceptione){}}}和命令行:javaThreadExcept1000哪一个是结果?()A.mainB.编译失败C.代码运行,但没有输出D.mainjava.lang.RuntimeException:exception

考题 classOrderimplementsRunnable{publicvoidrun(){try{Thread.sleep(2000);}catch(Exceptione)System.out.print(in);publicstaticvoidmain(String[]args){Threadt=newThread(newOrder());t.start();System.out.print(pre);try{t.join();}catch(Exceptione){}System.out.print(post);可产生哪两项结果?()A.preinpostB.preinC.inpostpreD.inprepostE.prepostin

考题 现有: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();}}以下哪两项是正确的?()

考题 publicclassAextendsThread{A(){setDaemon(true);}publicvoidrun(){(newB()).start();try{Thread.sleep(60000);}catch(InterruptedExceptionx){}System.out.println(Adone”);}classBextendsThread{publicvoidrun(){try{Thread.sleep(60000);}catch(InterruptedExceptionx){}System.out.println(Bdone”);}}publicstaticvoidmain(String[]args){(newA()).start();}}Whatistheresult?()A.AdoneB.BdoneC.AdoneBdoneD.BdoneAdoneE.Thereisnoexceptionthattheapplicationwillprintanything.F.Theapplicationoutputs“Adone”and“Bdone”,innoguaranteedorder.