classFlow{publicstaticvoidmain(String[]args){try{System.out.print("before");doRiskyThing();System.out.print("after");}catch(Exceptionfe){System.out.print("catch");}System.out.println("done");}publicstaticvoiddoRiskyThing()throwsException{//thiscodereturns

题目

classFlow{publicstaticvoidmain(String[]args){try{System.out.print("before");doRiskyThing();System.out.print("after");}catch(Exceptionfe){System.out.print("catch");}System.out.println("done");}publicstaticvoiddoRiskyThing()throwsException{//thiscodereturnsunlessitthrowsanException}}可能会产生下面哪两项结果?()

A.before

B.beforecatch

C.beforeafterdone

D.beforecatchdone


相似考题
参考答案和解析
参考答案:C, D
更多“classFlow{publicstaticvoidmain(String[]args){try{System.out.print("before");doRi ”相关问题
  • 第1题:

    staticvoidtest()throwsRuntimeException{try{System.out.print(”test);thrownewRuntimeException();}catch(Exceptionex){System.out.print(”exception);}}publicstaticvoidmain(String[]args){try{test();}catch(RuntimeExceptionex){System.out.print(”runtime);}System.out.print(”end);}Whatistheresult?()

    A.testend

    B.Compilationfails.

    C.testruntimeend

    D.testexceptionend

    E.AThrowableisthrownbymainatruntime.


    参考答案:D

  • 第2题:

    staticvoidtest()throwsError{if(true)thrownewAssertionError();System.out.print(”test);}publicstaticvoidmain(String[]args){try{test();}catch(Exceptionex){System.out.print(”exception);}System.out.print(”elld);}Whatistheresult?()

    A.end

    B.Compilationfails.

    C.exceptionend

    D.exceptiontestend

    E.AThrowableisthrownbymain.

    F.AnExceptionisthrownbymain.


    参考答案:E

  • 第3题:

    publicclassX{publicstaticvoidmain(String[]args){try{badMethod();System.out.print(A”);}catch(Exceptionex){System.out.print(B”);}finally{System.out.print(C”);}System.out.print(D”);}publicstaticvoidbadMethod(){}}Whatistheresult?()

    A.AC

    B.BD

    C.ACD

    D.ABCD

    E.Compilationfails.


    参考答案:C

  • 第4题:

    staticvoidtest(){try{Stringx=null;System.out.print(x.toString()+);}finally{System.out.print(finally);}}publicstaticvoidmain(String[]args){try{test();}catch(Exceptionex){System.out.print(”exception);}}Whatistheresult?()

    A.null

    B.finally

    C.nullfinally

    D.Compilationfails.

    E.finallyexception


    参考答案:E

  • 第5题:

    publicclassX{publicstaticvoidmain(String[]args){try{badMethod();System.out.print(A”);}catch(Exceptionex){System.out.print(B”);}finally{System.out.print(C”);}System.out.print(D”);}publicstaticvoidbadMethod(){thrownewRuntimeException();}}Whatistheresult?()

    A.AB

    B.BC

    C.ABC

    D.BCD

    E.Compilationfails.


    参考答案:D