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.inner
B.innerouter
C.middleouter
D.innermiddleouter
第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;}
}
结果是什么?()
第2题:
importjava.io.IOException;publicclassExceptionTest(publicstaticvoidmain(String[]args)try(methodA();)catch(IOExceptione)(system.out.printIn(CaughtIOException”);)catch(Exceptione)(system.out.printIn(CaughtException”);))publicvoidmethodA(){thrownewIOException();}Whatistheresult?()
A.Thecodewillnotcompile.
B.Theoutputiscaughtexception.
C.TheoutputiscaughtIOException.
D.Theprogramexecutesnormallywithoutprintingamessage.
第3题:
给定以下JAVA代码,这段代码编译运行后输出的结果是( )
publicclassTest{
publicstaticintaMethod(inti)throwsException{
try{
returni/10;
}catch(Exceptionex){
thrownewException("exceptioninaaMothod");
}finally{
System.out.print("finally");
}
}
publicstaticvoidmain(String[]args){
try{
aMethod(0);
}catch(Exceptionex){
System.out.print("exceptioninmain");
}
System.out.print("finished");
}
}
A、finallyexceptioninmainfinished
B、exceptioninmainfinally
C、finallyfinished
D、finallyexceptioninmainfinished
第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..编译失败
第5题:
publicclassTest{publicstaticvoidaMethod()throwsException{try{thrownewException();}finally{System.out.println(finally”);}}publicstaticvoidmain(Stringargs[]){try{aMethod();}catch(Exceptione){System.out.println(exception”);}System.out.println(finished”);}}Whatistheresult?()
A.finally
B.exceptionfinished
C.finallyexceptionfinished
D.Compilationfails.