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

题目
现有:t是一个合法的Thread对象的引用,并且t的合法run()方法如下:publicvoidrun(){System.out.print("go");}及:t.start();t.start();t.run();哪一个是结果?()

A.gogo

B.gogogo

C.go之后跟着一个异常

D.gogo之后跟着一个异常


相似考题
更多“现有:t是一个合法的Thread对象的引用,并且t的合法run()方法如下:publicvoidrun(){System.out.print("go");}及:t.start();t.start();t.run();哪一个是结果?() ”相关问题
  • 第1题:

    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.


    参考答案:B

  • 第2题:

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


    参考答案:E

  • 第3题:

    已经声明了类“publicclassthimplementsrunnable”,下面哪条语句可以启动该类型的线程_________?

    A.Tht=newTh();t.start();

    B.newTh.start();

    C.Threadt=newThread(newTh());t.start();

    D.Tht=newTh();t.run();


    正确答案:C

  • 第4题:

    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.


    参考答案:B

  • 第5题:

    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();


    参考答案:A