网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
Runnabler=newRunnable(){publicvoidrun(){System.out.print(”Cat”);}};Threadt=newThread(r){publicvoidrun(){System.out.print(”Dog”);}};t.start();Whatistheresult?()
A.Cat
B.Dog
C.Compilationfails.
D.Thecoderunswithnooutput.
E.Anexceptionisthrownatruntime.
参考答案
更多 “ 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. ” 相关考题
考题
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
考题
publicclassTestOneimplementsRunnable{publicstaticvoidmain(String[]args)throwsException{Threadt=newThread(newTestOne());t.start();System.out.print(”Started”);t.join();System.out.print(”Complete”);}publicvoidrun(){for(inti=0;i4;i++){System.out.print(i);}}}Whatcanbearesult?()A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thecodeexecutesandprints“StartedComplete”.D.Thecodeexecutesandprints“StartedComplete0123”.E.Thecodeexecutesandprints“Started0l23Complete”.
考题
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.
考题
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”.
考题
WhichtwocodefragmentswillexecutethemethoddoStuff()inaseparatethread?()
A.newThread(){publicvoidrun(){doStuff();}}B.newThread(){publicvoidstart(){doStuff();}}C.newThread(){publicvoidstart(){doStuff();}}.run();D.newThread(){publicvoidrun(){doStuff();}}.start();E.newThread(newRunnable(){publicvoidrun(){doStuff();}}).run();F.newThread(newRunnable(){publicvoidrun(){doStuff();}}).start();
考题
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();
考题
classMyThreadextendsThread{publicvoidrun(){System.out.println(AAA”);}publicvoidrun(Runnabler){System.out.println(BBB”);}publicstaticvoidmain(String[]args){newThread(newMyThread()).start();}}Whatistheresult?()A.AAAB.BBBC.Compilationfails.D.Thecoderunswithnooutput.
热门标签
最新试卷