题目内容

什么是异常?什么是重量级异常?什么是轻量级异常?

查看答案
更多问题

Java异常处理中throw和throws关键字的区别。

如果在一个方法内出现了一个异常并抛出异常,方法内又没有异常处理代码块,将会发生什么情况?

下列程序段的输出结果是什么?public class test{public static void main(String args[]){int flag=90;try{System.out.println("try-catch entered");if(flag>=0)throw new Exception("The grade is A");System.out.println("Exception is:"+e.getMessage());}finally{System.out.println("after catch-block");}}}}输出结果是什么?如果修改flag为80,则结果又是什么?

请在下面程序段中的合适位置加上throws关键字,使程序正确。public static void procedure(int n){if(n<0) throw new Exception(“negative number”);}

答案查题题库