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

题目内容 (请给出正确答案)
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(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. ” 相关考题
考题 阅读下列代码 public class Test implements Runnable{ public void run(Thread t){ System. out. println("Running. "); } public static void main(String[]args){ Thread tt=new Thread(new Test()); tt. start(); } } 代码运行结果是A.将抛出一个异常B.没有输出并正常结束C.输出“Running”并正常结束D.程序第2行将出现一个编译错误

考题 1.classMyThreadimplementsRunnable{2.publicvoidrun(){3.System.out.print(go);4.}5.6.publicstaticvoidmain(String[]args){7.//insertcodehere8.t.start();9.}10.}和如下四句:Threadt=newMyThread();MyThreadt=newMyThread();Threadt=newThread(newThread());Threadt=newThread(newMyThread());分别插入到第5行,有几个可以通过编译?()A.0B.1C.2D.3

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

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

考题 classTestSuper{22.TestSuper(inti){}3.}4.classTestSubextendsTestSuper{}5.classTestAll{6.publicstaticvoidmain(String[]args){7.newTestSub();8.}9.}Whichistrue?() A.Compilationfails.B.Thecoderunswithoutexception.C.Anexceptionisthrownatline7.D.Anexceptionisthrownatline2.

考题 publicclassFooimplementsRunnable(publicvoidrun(Threadt){system.out.printIn(Running.”);}publicstaticvoidmain(Stringargs){newthread(newFoo()).start();})Whatistheresult?() A.Anexceptionisthrown.B.Theprogramexistswithoutprintinganything.C.Anerroratline1causescompilationtofail.D.Anerroratline6causesthecompilationtofail.E.“Running”isprintedandtheprogramexits.

考题 main()方法的正确定义方式是()。A.public static void main (String [ ] args ) { new NameSurfer().start (args ) ; }B.public static main (String [ ] args ) { new NameSurfer().start (args ) ; }C.public void main (String [ ] args ) { new NameSurfer().start (args ) ; }D.public static void main (String [ ] args ) { NameSurfer().start (args ) ; }

考题 【单选题】请看下面未完成的代码 public class Foo implements Runnable { public void run (Thread t) { System.out.println("Running."); } public static void main (String[] args) { new Thread(new Foo()).start(); } } 结果是?A.运行时抛出一个异常B.程序能够运行,但是没有任何输出C.没有实现 Runnable 接口中的方法导致编译错误D.程序运行后输出“Running”