网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

在代码中使用catch(Exceptione)的好处是()。

  • A、只会捕获个别类型的异常
  • B、捕获try块中产生的所有类型的异常
  • C、忽略一些异常
  • D、执行一些程序

参考答案

更多 “在代码中使用catch(Exceptione)的好处是()。A、只会捕获个别类型的异常B、捕获try块中产生的所有类型的异常C、忽略一些异常D、执行一些程序” 相关考题
考题 如下代码:publicvoidTest(){try{oneMethod();System.out.println(condition1);}catch(ArrayIndexOutOfBoundsExceptione){System.out.println(condition2);}catch(Exceptione){System.out.println(condition3);}finally{System.out.println(finally);}}如果oneMethod正常运行,则输出结果中是?()A.condition1finallyB.condition2finallyC.condition3finallyD.finally

考题 下列程序的输出结果是( )。 PublicclassTest{ Publicstaticvoidmain(String[]args){ int[]array=(2,4,6,8,10); intsize=6; intresult=-1; try{ for(inti=0;i<sizeresult==-1;) if(array[i]==20)result=i; } catch(ArithmeticExceptione){ System.out.println("Catch---1"); } catch(Array IndexOutOfBoundsExceptione){ System.out.println("Catch---2"); } catch(Exceptione){ System.out.println("Catch---3"); } }A.Catch---1B.Catch---2C.Catch---3D.以上都不对

考题 classThreadExceptimplementsRunnable{publicvoidrun(){thrownewRuntimeException(exception);}publicstaticvoidmain(String[]args){newThread(newThreadExcept()).start();try{intx=Integer.parseInt(args[0]);Thread.sleep(x);System.out.print(main);}catch(Exceptione){}}}和命令行:javaThreadExcept1000哪一个是结果?()A.mainB.编译失败C.代码运行,但没有输出D.mainjava.lang.RuntimeException:exception

考题 classWaitingimplementsRunnable{booleanflag=false;publicsynchronizedvoidrun(){if(flag){flag=false;System.out.print(1);try{this.wait();}catch(Exceptione){}System.out.print(2);}else{flag=true;System.out.print(3);try{Thread.sleep(2000);}catch(Exceptione){}System.out.print(4);notify();}}publicstaticvoidmain(String[]args){Waitingw=newWaiting();newThread(w).start();newThread(w).start();}}以下哪两项是正确的?()

考题 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.inpreB.preinC.inprepostD.preinpost

考题 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.innerB.innerouterC.middleouterD.innermiddleouter

考题 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.3B.2C.231D.32

考题 现有: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.innerouterB.middleouterC.innermiddleouterD..编译失败

考题 现有:voidtopGo(){try{middleGo();}catch(Exceptione){System.out.print(catch);}}voidmiddleGo()throwsException{go();system.out.print(latemiddle);}voidgo()throwsExceptiOn{thrownewException();}如果调用topGo(),则结果为:()A.latemiddleB.catchC.latemiddlecatchD.catchIatemiddle

考题 下列关于捕获异常的描述中,错误的是______。A.在异常处理代码段中无法访问hy代码段中声明的变量B.子类异常可被父类异常捕获处理C.try-catch机制可以被用于流程控制D.在catch代码段中的return语句用于退出方法,而不是返回异常抛出点

考题 publicclassExceptionTest{classTestExceptionextendsException{}publicvoidrunTest()throwsTestException{}publicvoidtest()/*PointX*/{runTest();}}AtpointXonline4,whichcodecanbeaddedtomakethecodecompile?() A.ThrowsException.B.Catch(Exceptione).C.ThrowsRuntimeException.D.Catch(TestExceptione).E.Nocodeisnecessary.

考题 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.

考题 try{if((newObject))(.equals((newObject()))){System.out.println(equal”);}else{System.out.println(notequal”);}}catch(Exceptione){System.out.println(exception”);}Whatistheresult?() A.equalB.notequalC.exceptionD.Compilationfails.

考题 try{intx=0;inty=5/x;}catch(Exceptione){System.out.println(Exception”);}catch(ArithmeticExceptionae){System.out.println(ArithmeticException”);}System.out.println(finished”);Whatistheresult?() A.finishedB.ExceptionC.Compilationfails.D.ArithmeticException

考题 1.publicclassExceptionTest{2.classTestExceptionextendsException{}3.publicvoidrunTest()throwsTestException{}4.publicvoidtest()/*PointX*/{5.runTest();6.}7.}AtPointXonline4,whichcodeisnecessarytomakethecodecompile?()A.Nocodeisnecessary.B.throwsExceptionC.catch(Exceptione)D.throwsRuntimeExceptionE.catch(TestExceptione)

考题 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.

考题 下列关于try和catch语句的描述中,错误的是______。A.不同的catch代码段是不同的作用域,但是可以访问相互之间定义的局部变量B.如果没有异常产生,则所有的catch代码段都被略过不执行C.异常总是由距离产生异常最近的匹配catch代码段处理D.try代码段后跟一个或多个catch代码段

考题 下列描述中,正确的是______。A.finally代码段在发生异常时不一定必须执行B.异常机制可以用于流程控制C.在catch代码段中可以使用return语句来返回到异常抛出点D.可以把catch到的异常对象再次抛出,使上层try-atch结构继续处理该异常事件

考题 下列关于try和catch子句的描述中,错误的一项是 ( )A.不同的catch代码段是不同的作用域,但是可以访问相互之间定义的局部变量B.如果没有异常产生,则所有的catch代码段都被略过不执行C.try代码段后跟有一个或多个catch代码段D.异常总是由距离产生异常最近的匹配catch代码段处理

考题 下列关于C#的异常处理的说发法,错误的是()。A、Try块必须跟catch块组合使用,不能单独使用B、一个try块可以跟随多个catch块C、使用throw语句既可引发系统异常,也可以引发由开发人员创建的自定义异常D、在try…catch…..finally块中,即便开发人员编写强制逻辑代码,也不能跳出finally块的执行

考题 在Java中,关于捕获错误的语法try  -  catch -  finally的说法正确的是()     A、try – catch 必须配对使用B、try 可以单独使用C、try – finally 可以配对使用D、在 tru – catch 后如果定义了finally肯定会执行

考题 在Java的异常处理语句try-catch-final中,以下描述不正确的是()。A、try后面是可能产生异常的代码,catch后面是捕获到某种异常对象时进行处理的代码,final后面是没有捕获到异常时要执行的代码B、try后面是可能产生异常的代码,catch后面是捕获到某种异常对象时进行处理的代码,final后面是无论是否捕获到异常都必须执行的代码C、catch语句和final语句都可以缺省D、catch语句用来处理程序运行时的非致命性错误,而final语句用来处理程序运行时的致命性错误E、当程序运行时抛出的异常是cathe语句中异常的子类,异常也会被捕捉执行相应的catch语句

考题 在代码中,使用catch(Exceptione)的好处是()。A、只会捕获个别类型的异常B、捕获try块中产生的所有类型的异常C、忽略一些异常D、执行一些程序

考题 关于catch代码块说法正确的是()A、 包含有可能会引发异常的语句块B、 声明有可能会引发异常的类型C、 一般不与try块配合使用,单独使用D、 异常处理程序位于catch代码块中。

考题 单选题在代码中,使用catch(Exceptione)的好处是()。A 只会捕获个别类型的异常B 捕获try块中产生的所有类型的异常C 忽略一些异常D 执行一些程序

考题 单选题在代码中使用catch(Exceptione)的好处是()。A 只会捕获个别类型的异常B 捕获try块中产生的所有类型的异常C 忽略一些异常D 执行一些程序

考题 单选题关于catch代码块说法正确的是()A  包含有可能会引发异常的语句块B  声明有可能会引发异常的类型C  一般不与try块配合使用,单独使用D  异常处理程序位于catch代码块中。