网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
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”.
参考答案
更多 “ 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”. ” 相关考题
考题
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
考题
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.
考题
publicclassThreads5{publicstaticvoidmain(String[]args){newThread(newRunnable(){publicvoidrun(){System.out.print(”bar”);}}).start();}}Whatistheresult?()
A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thecodeexecutesnormallyandprints“bar”.D.Thecodeexecutesnormally,butnothingprints.
考题
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.
考题
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();
考题
publicclassFooimplementsRunnable(3.publicvoidrun(Threadt){4.system.out.printIn(Running.”);5.}6.publicstaticvoidmain(String[]args){7.newthread(newFoo()).start();8.)9.)Whatistheresult?()
A.Anexceptionisthrown.B.Theprogramexistswithoutprintinganything.C.Anerroratline1causescompilationtofail.D.Anerroratline6causesthecompilationtofail.E.“Running”isprintedandtheprogramexits.
考题
publicclassFooimplementsRunnable(publicvoidrun(Threadt){system.out.printIn(Running.”);}publicstaticvoidmain(String[]args){newthread(newFoo()).start();})Whatistheresult?()
A.Anexceptionisthrown.B.Theprogramexistswithoutprintinganything.C.Anerroratline1causescompilationtofail.D.Anerroratline2causesthecompilationtofail.E.“Running”isprintedandtheprogramexits.
考题
阅读下面程序 public class Test implements Runnable { public static void main(String[] args) { ______ t.start(); } public void run() { System.out.println("Hello!"); } } 程序中下画线处应填入的正确选项是A.Test t=new Test();B.Thread t=new Thread();C.Thread t=new Thread(new Test());D.Test t=new Thread();
热门标签
最新试卷