以下程序段的输出结果为 .以下程序段的输出结果为 .\x05public class TryCatchFinally{\x05static void Proc( int sel ){\x05\x05try{\x05\x05 if( sel==0 ){System.out.print("no Exception ");\x05\x05\x05\x05return;}\x05\x05 else if( sel==

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 07:40:07
以下程序段的输出结果为 .以下程序段的输出结果为 .\x05public class TryCatchFinally{\x05static void Proc( int sel ){\x05\x05try{\x05\x05 if( sel==0 ){System.out.print(

以下程序段的输出结果为 .以下程序段的输出结果为 .\x05public class TryCatchFinally{\x05static void Proc( int sel ){\x05\x05try{\x05\x05 if( sel==0 ){System.out.print("no Exception ");\x05\x05\x05\x05return;}\x05\x05 else if( sel==
以下程序段的输出结果为 .
以下程序段的输出结果为 .
\x05public class TryCatchFinally{
\x05static void Proc( int sel ){
\x05\x05try{
\x05\x05 if( sel==0 ){System.out.print("no Exception ");
\x05\x05\x05\x05return;}
\x05\x05 else if( sel==1 ){ int j = 4/0; }
\x05\x05\x05}
\x05\x05catch( ArithmeticException e ) {
\x05\x05\x05System.out.print("catch "); }
\x05\x05catch( Exception e ) {
\x05\x05\x05System.out.print("will not be executed ");}
\x05\x05finally{
\x05\x05\x05System.out.print("finally "); \x05}
\x05}
public static void main( String args[] ){
\x05 Proc( 1 ); \x05}
\x05}

以下程序段的输出结果为 .以下程序段的输出结果为 .\x05public class TryCatchFinally{\x05static void Proc( int sel ){\x05\x05try{\x05\x05 if( sel==0 ){System.out.print("no Exception ");\x05\x05\x05\x05return;}\x05\x05 else if( sel==
打印结果为: catch finally .第二个 catch 不输出
这段代码考查的是try catch finally 的执行顺序.怎么捕获异常的.
与 switch 相关,遇到第一个满足条件则执行.然后跳到finally.
类似于switch 中的case break; default..