现在的位置: 首页 > 综合 > 正文

JAVA面试题目(异常处理流程)

2013年10月02日 ⁄ 综合 ⁄ 共 559字 ⁄ 字号 评论关闭

  下边的代码运行后会输出什么,编译能通过吗

 package cn.com.test;
public class ExceptionTest {
 
 public static void main(String[] args){
       try{
              badMethod();
              System.out.println("badMethod over");
        }catch(RuntimeException re){
              System.out.println("RuntimeException");
        }catch(Exception ex){
              System.out.println("other Excepiton");
       }finally{
              System.out.println("finally");
       }
       System.out.println("all over");
       }
 
 public static void badMethod(){
       throw new RuntimeException();
 }
}
正确的输出结果是:
RuntimeException
finally
all over
 

抱歉!评论已关闭.