在代码中使用catch(Exceptione)的好处是()。
第1题:
classOrderimplementsRunnable{publicvoidrun(){try{Thread.sleep(2000);}catch(Exceptione){}System.out.print("in");}publicstaticvoidmain(String[]args){Threadt=newThread(newOrder());t.start();System.out.print("pre");try{t.join();}catch(Exceptione){}System.out.print("post");}}可产生哪两项结果?()
A.inpre
B.prein
C.inprepost
D.preinpost
第2题:
publicclassTestApp{publicstaticvoidmain(String[]args){try{inti=0;intj=1/i;Stringmyname=null;if(myname.length()>2)System.out.print(1”);}catch(NullPointerExceptione){System.out.print(2”);}catch(Exceptione){System.out.print(3”);}}}上述程序运行后的输出是哪项?()
A.3
B.2
C.231
D.32
第3题:
现有:voidtopGo(){try{middleGo();}catch(Exceptione){System.out.print("catch");}}voidmiddleGo()throwsException{go();system.out.print("latemiddle");}voidgo()throwsExceptiOn{thrownewException();}如果调用topGo(),则结果为:()
A.latemiddle
B.catch
C.latemiddlecatch
D.catchIatemiddle
第4题:
A.ThrowsException.
B.Catch(Exceptione).
C.ThrowsRuntimeException.
D.Catch(TestExceptione).
E.Nocodeisnecessary.
第5题:
A.equal
B.notequal
C.exception
D.Compilationfails.
第6题:
1.publicclassExceptionTest{2.classTestExceptionextendsException{}3.publicvoidrunTest()throwsTestException{}4.publicvoidtest()/*PointX*/{5.runTest();6.}7.}AtPointXonline4,whichcodeisnecessarytomakethecodecompile?()
A.Nocodeisnecessary.
B.throwsException
C.catch(Exceptione)
D.throwsRuntimeException
E.catch(TestExceptione)
第7题:
下列关于try和catch语句的描述中,错误的是______。
A.不同的catch代码段是不同的作用域,但是可以访问相互之间定义的局部变量
B.如果没有异常产生,则所有的catch代码段都被略过不执行
C.异常总是由距离产生异常最近的匹配catch代码段处理
D.try代码段后跟一个或多个catch代码段
第8题:
下列关于try和catch子句的描述中,错误的一项是 ( )
A.不同的catch代码段是不同的作用域,但是可以访问相互之间定义的局部变量
B.如果没有异常产生,则所有的catch代码段都被略过不执行
C.try代码段后跟有一个或多个catch代码段
D.异常总是由距离产生异常最近的匹配catch代码段处理
第9题:
在Java中,关于捕获错误的语法try - catch - finally的说法正确的是()
第10题:
在代码中,使用catch(Exceptione)的好处是()。
第11题:
只会捕获个别类型的异常
捕获try块中产生的所有类型的异常
忽略一些异常
执行一些程序
第12题:
包含有可能会引发异常的语句块
声明有可能会引发异常的类型
一般不与try块配合使用,单独使用
异常处理程序位于catch代码块中。
第13题:
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
第14题:
现有: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..编译失败
第15题:
下列关于捕获异常的描述中,错误的是______。
A.在异常处理代码段中无法访问hy代码段中声明的变量
B.子类异常可被父类异常捕获处理
C.try-catch机制可以被用于流程控制
D.在catch代码段中的return语句用于退出方法,而不是返回异常抛出点
第16题:
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.
第17题:
A.finished
B.Exception
C.Compilationfails.
D.ArithmeticException
第18题:
importjava.io.IOException;publicclassExceptionTest(publicstaticvoidmain(Stringargs)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.
第19题:
下列描述中,正确的是______。
A.finally代码段在发生异常时不一定必须执行
B.异常机制可以用于流程控制
C.在catch代码段中可以使用return语句来返回到异常抛出点
D.可以把catch到的异常对象再次抛出,使上层try-atch结构继续处理该异常事件
第20题:
下列关于C#的异常处理的说发法,错误的是()。
第21题:
在Java的异常处理语句try-catch-final中,以下描述不正确的是()。
第22题:
关于catch代码块说法正确的是()
第23题:
只会捕获个别类型的异常
捕获try块中产生的所有类型的异常
忽略一些异常
执行一些程序