itgle.com

publicclassTestOne{publicstaticvoidmain(String[]args)throwsException{Thread.sleep(3000);System.out.println(”sleep”);}}Whatistheresult?()A.Compilationfails.B.Anexceptionisthrownatruntime.C.Thecodeexecutesnormallyandprints“sleep”.D.Thecodeexecutesnormally,b

题目
publicclassTestOne{publicstaticvoidmain(String[]args)throwsException{Thread.sleep(3000);System.out.println(”sleep”);}}Whatistheresult?()

A.Compilationfails.

B.Anexceptionisthrownatruntime.

C.Thecodeexecutesnormallyandprints“sleep”.

D.Thecodeexecutesnormally,butnothingisprinted.


相似考题
更多“publicclassTestOne{publicstaticvoidmain(String[]args)throwsException{Thread.sleep(3000);System.out.println(”sleep”);}}Whatistheresult?() ”相关问题
  • 第1题:

    publicclassTest{privatestaticint[]x;publicstaticvoidmain(String[]args){System.out.println(x[0]);}}Whatistheresult?()

    A.0

    B.null

    C.Compilationfails.

    D.ANullPointerExceptionisthrownatruntime.

    E.AnArrayIndexOutOfBoundsExceptionisthrownatruntime.


    参考答案:D

  • 第2题:

    classMyThreadextendsThread{publicvoidrun(){System.out.println(AAA”);}publicvoidrun(Runnabler){System.out.println(BBB”);}publicstaticvoidmain(String[]args){newThread(newMyThread()).start();}}Whatistheresult?()

    A.AAA

    B.BBB

    C.Compilationfails.

    D.Thecoderunswithnooutput.


    参考答案:A

  • 第3题:

    publicclassFoo{publicstaticvoidmain(String[]args){try{return;}finally{System.out.println(Finally”);}}}Whatistheresult?()

    A.Finally

    B.Compilationfails.

    C.Thecoderunswithnooutput.

    D.Anexceptionisthrownatruntime.


    参考答案:A

  • 第4题:

    publicclassAextendsThread{A(){setDaemon(true);}publicvoidrun(){(newB()).start();try{Thread.sleep(60000);}catch(InterruptedExceptionx){}System.out.println(Adone”);}classBextendsThread{publicvoidrun(){try{Thread.sleep(60000);}catch(InterruptedExceptionx){}System.out.println(Bdone”);}}publicstaticvoidmain(String[]args){(newA()).start();}}Whatistheresult?()

    A.Adone

    B.Bdone

    C.AdoneBdone

    D.BdoneAdone

    E.Thereisnoexceptionthattheapplicationwillprintanything.

    F.Theapplicationoutputs“Adone”and“Bdone”,innoguaranteedorder.


    参考答案:B

  • 第5题:

    publicclassTest{publicstaticvoidmain(String[]args){intx=0;assert(x>0):“assertionfailed”;System.out.println(“finished”);}}Whatistheresult?()

    A.finished

    B.Compilationfails.

    C.AnAssertionErroristhrown.

    D.AnAssertionErroristhrownandfinishedisoutput.


    参考答案:A

    Thisquestionisabittrickybecauseitlacksthefollowinginformation:Itshouldincludeastatementthatsayswhetherornotassertionsareenabled.Iftheyareindeedenabled,the
    correctionanswerisC.butiftheyarenot,thecorrectanswerisA.Assertionsarenotenabledbydefaultsoifthequestionisnotchanged,themostlogicalanswerisA.