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

题目内容 (请给出正确答案)
t是一个合法的Thread对象的引用,并且t的合法run()方法如下:publicvoidrun(){System.out.print("go");}及:t.start();t.start();t.run();哪一个是结果?()

A.go

B.gogo

C.gogogo

D.go之后跟着一个异常


参考答案

更多 “ t是一个合法的Thread对象的引用,并且t的合法run()方法如下:publicvoidrun(){System.out.print(go);}及:t.start();t.start();t.run();哪一个是结果?() A.goB.gogoC.gogogoD.go之后跟着一个异常 ” 相关考题
考题 classThread2implementsRunnable{voidrun(){System.out.print(go);}publicstaticvoidmain(String[]args){Thread2t2=newThread2();Threadt=newThread(t2);t.start();}}结果为:() A.goB.编译失败C.代码运行,无输出结果D.运行时异常被抛出

考题 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

考题 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

考题 现有:t是一个合法的Thread对象的引用,并且t的合法run()方法如下:publicvoidrun(){System.out.print(go);}及:t.start();t.start();t.run();哪一个是结果?() A.gogoB.gogogoC.go之后跟着一个异常D.gogo之后跟着一个异常

考题 Runnabler=newRunnable(){publicvoidrun(){System.out.print(”Cat”);}};Threadt=newThread(r){publicvoidrun(){System.out.print(”Dog”);}};t.start();Whatistheresult?() A.CatB.DogC.Compilationfails.D.Thecoderunswithnooutput.E.Anexceptionisthrownatruntime.

考题 publicclassThreads4{publicstaticvoidmain(String[]args){newThreads4().go();}publicvoidgo(){Runnabler=newRunnable(){publicvoidrun(){System.out.print(”foo”);}};Threadt=newThread(r);t.start();t.start();}}Whatistheresult?()A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thecodeexecutesnormallyandprints?foo”.D.Thecodeexecutesnormally,butnothingisprinted.

考题 publicclassThreads3implementsRunnable{publicvoidrun(){System.out.print(”running”);}publicstaticvoidmain(String[]args){Threadt=newThread(newThreads3());t.run();t.run();t.start();}}Whatistheresult?() A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thecodeexecutesandprints“running”.D.Thecodeexecutesandprints“runningrunning”.E.Thecodeexecutesandprints“runningrunningrunning”.

考题 GiventhatastaticmethoddoIt()inaclassWorkrepresentsworktobedone,whatblockofcodewillsucceedinstartinganewthreadthatwilldothework?CODEBLOCKa:Runnabler=newRunnable(){publicvoidrun(){Work.doIt();}};Threadt=newThread(r);t.start();CODEBLOCKb:Threadt=newThread(){publicvoidstart(){Work.doIt();}};t.start();CODEBLOCKc:Runnabler=newRunnable(){publicvoidrun(){Work.doIt();}};r.start();CODEBLOCKd:Threadt=newThread(newWork());t.start();CODEBLOCKe:Runnablet=newRunnable(){publicvoidrun(){Work.doIt();}};t.run();

考题 已经声明了类“publicclassthimplementsrunnable”,下面哪条语句可以启动该类型的线程_________? A.Tht=newTh();t.start();B.newTh.start();C.Threadt=newThread(newTh());t.start();D.Tht=newTh();t.run();