异常
- 格式:doc
- 大小:27.50 KB
- 文档页数:2
下列常见的系统定义的异常中,哪个是输入、输出异常?( )
A、ClassNotFoundException
B、IOException
C、FileNotFoundException
D、UnknownHostException
解答:B
知识点列表:8.1 异常处理:异常与异常类、抛出异常、异常的捕获。
异常包含下列哪一个内容? ( )
A、程序中的语法错误
B、程序的编译错误
C、程序执行过程中遇到的事先没有预料到的情况
D、程序事先定义好的可能出现的意外情况
解答:C
知识点列表:8.1 异常处理:异常与异常类、抛出异常、异常的捕获。
分析下面的Java程序段输出结果为( )。
public class yy {
public static void main(String[] args) throws Exception {
try {
throw new Exception();
}catch(Exception e){
System.out.println("Caught in main()");
}
System.out.println("nothing");
}
}
A、 Caught in main() B、Caught in main()
nothing
C、nothing D、没有任何输出
解答:A
知识点列表:8.1 异常处理:异常与异常类、抛出异常、异常的捕获。
1、写出以下程序的运行结果。(无答案)
class MyException extends Exception{
private int detail;
MyException( int a ){ detail = a;}
public String toString( ){ return "MyException "+detail; }
}
public class ExceptionDemo{
public static void compute(int a) throws MyException {
System.out.println("called compute("+a+")");
if( a>10 ) throw new MyException(a); System.out.println("normal exit"); }
public static void main( String args[] ){
try{ compute(6 ); compute( 12 ); }
catch( MyException e ){ System.out.println("Caught "+e); } }
}
1、异常包含下列哪些内容?no key
A)程序中的语法错误 B)程序执行过程中遇到的事先没有预料到的情况
C)程序的编译错误 D)程序事先定义好的可能出现的意外情况