itgle.com

11.classa{12.publicvoidprocess(){System.out.print(”a,”);}}13.classbextendsa{14.publicvoidprocess()throwsIOException{15.super.process();16.System.out.print(”b,”);17.thrownewIOException();18.}}19.publicstaticvoidmain(String[]args){20.try{newb().process();}2

题目

11.classa{12.publicvoidprocess(){System.out.print(”a,”);}}13.classbextendsa{14.publicvoidprocess()throwsIOException{15.super.process();16.System.out.print(”b,”);17.thrownewIOException();18.}}19.publicstaticvoidmain(String[]args){20.try{newb().process();}21.catch(IOExceptione){System.out.println(”Exception”);}}Whatistheresult?()

A.Exception

B.a,b,Exception

C.Compilationfailsbecauseofanerrorinline20.

D.Compilationfailsbecauseofanerrorinline14.

E.ANullPointerExceptionisthrownatruntime.


相似考题
参考答案和解析
参考答案:D
更多“classa{12.publicvoidprocess(){System.out.print(”a,”);}}13.classbextendsa{14.publicvoidp ”相关问题
  • 第1题:

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

    A.ABCD

    B.Compilationfails.

    C.Cisprintedbeforeexitingwithanerrormessage.

    D.BCisprintedbeforeexitingwithanerrormessage.

    E.BCDisprintedbeforeexitingwithanerrormessage.


    参考答案:B
    Thecorrectansweris:Bisprintedandthenanerrormessageisprinted.TheexceptioncatchcannotcatchanErrorbecausethisclassdoesnotextendExceptionbutitimplementsthrowable.

  • 第2题:

    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

  • 第3题:

    下面能表示一个正确的类的是( )。

    A.class A

    B.class A()

    C.class A[]

    D.class A{}


    正确答案:D
    解析:类声明的格式。

  • 第4题:

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

    A.BD

    B.BCD

    C.BDE

    D.BCDE

    E.ABCDE

    F.Compilationfails.


    参考答案:C

  • 第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(){}}Whatistheresult?()

    A.AC

    B.BD

    C.ACD

    D.ABCD

    E.Compilationfails.


    参考答案:C