现有:classParserextendsUtils{publicstaticvoidmain(String[]args){try{System.out.print(newParser().getlnt("42"));}catch(Exceptione){System.out.println("Exc");}}intgetlnt(Stringarg)throwsException{returnInteger.parselnt(arg);}classUtils{intgetlnt(Stringarg){re

题目

现有:classParserextendsUtils{publicstaticvoidmain(String[]args){try{System.out.print(newParser().getlnt("42"));}catch(Exceptione){System.out.println("Exc");}}intgetlnt(Stringarg)throwsException{returnInteger.parselnt(arg);}classUtils{intgetlnt(Stringarg){return42;}}结果为()

A.42

B.Exc

C.42Exc

D.编译失败


相似考题
更多“现有:classParserextendsUtils{publicstaticvoidmain(String[]args){try{System.out.print(newPa ”相关问题
  • 第1题:

    现有

    classParserextendsUtils{

    publicstaticvoidmain(String[]args){

    try{System.out.print(newParser().getlnt("42"))

    }catch(Exceptione){

    System.out.println("Exc");}

    }

    intgetlnt(Stringarg)throwsException{

    returnInteger.parselnt(arg);

    }

    }

    classUtils{

    intgetlnt(){return42;}

    }

    结果是什么?()


    参考答案:C

  • 第2题:

    现有: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.beforecatch

    B.beforeafterdone

    C.beforecatchdone

    D.beforeaftercatch


    参考答案:B, C

  • 第3题:

    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

  • 第4题:

    现有:classBirds{publicstaticvoidmain(String[]args){try{thrownewException();}catch(Exceptione){try{thrownewException();}catch(Exceptione2){System.out.print("inner");}System.out.print("middle");}System.out.print("outer");}}结果是()

    A.innerouter

    B.middleouter

    C.innermiddleouter

    D..编译失败


    参考答案:C

  • 第5题:

    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