itgle.com

11.classA{12.publicvoidprocess(){System.out.print(”A);}}13.classBextendsA{14.publicvoidprocess()throwsRuntimeException{15.super.process();16.if(true)thrownewRuntimeException();17.System.out.print(B”);}}18.publicstaticvoidmain(String[]args){19.try{((A)newB

题目

11.classA{12.publicvoidprocess(){System.out.print(”A);}}13.classBextendsA{14.publicvoidprocess()throwsRuntimeException{15.super.process();16.if(true)thrownewRuntimeException();17.System.out.print(B”);}}18.publicstaticvoidmain(String[]args){19.try{((A)newB()).process();}20.catch(Exceptione){System.out.print(”Exception);}21.}Whatistheresult?()

A.Exception

B.AException

C.AExceptionB

D.ABException

E.Compilationfailsbecauseofanerrorinline14.

F.Compilationfailsbecauseofanerrorinline19.


相似考题
更多“classA{12.publicvoidprocess(){System.out.print(”A);}}13.classBextendsA{14.publicvoidpro ”相关问题
  • 第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