简述RuntimeException和Exception的区别。
第1题:
A.继承java.lang.Error的类属于checkedexception
B.checked异常继承java.lang.Exception类
C.unchecked异常继承java.lang.RuntimeException类
D.NullPointerException,IllegalArgumentException属于uncheckedexception
第2题:
error和exception有什么区别?
第3题:
简述Error和Exception的区别。
第4题:
class ThreadExcept implements Runnable { public void run() { throw new RuntimeException("exception "); } public static void main(String [] args) { new Thread(new ThreadExcept()).start(); try { int x = Integer.parseInt(args[0]); Thread.sleep(x); System.out.print("main "); } catch (Exception e) { } } } 和命令行: java ThreadExcept 1000 哪一个是结果?()
第5题:
下面有关JAVA异常类的描述,说法错误的是()。
第6题:
public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (Exception ex) { System.out.print(“B”); } finally { System.out.print(“C”); } System.out.print(“D”); } public static void badMethod() { throw new RuntimeException(); } } What is the result? ()
第7题:
第8题:
第9题:
test end
Compilation fails.
test runtime end
test exception end
A Throwable is thrown by main at runtime.
第10题:
Exception
A Exception
A Exception B
A B Exception
Compilation fails because of an error in line 14.
Compilation fails because of an error in line 19.
第11题:
main
编译失败
代码运行,但没有输出
main java.lang.RuntimeException:exception
第12题:
第13题:
static void test() throws RuntimeException { try { System.out.print(”test “); throw new RuntimeException(); } catch (Exception ex) { System.out.print(”exception “); } } public static void main(String[] args) { try { test(); } catch (RuntimeException ex) { System.out.print(”runtime “); } System.out.print(”end “); } What is the result?()
第14题:
Error与Exception有什么区别?
第15题:
public class ExceptionTest { class TestException extends Exception {} public void runTest () throws TestException {} public void test () /* Point X*/ { runTest (); } } At point X on line 4, which code can be added to make the code compile?()
第16题:
Error和Exception有是区别?
第17题:
public class X { public static void main(String [] args) { try { badMethod(); System.out.print(“A”); } catch (RuntimeException ex) { System.out.print(“B”); } catch (Exception ex1) { System.out.print(“C”); } finally { System.out.print(“D”); } System.out.print(“E”); } public static void badMethod() { throw new RuntimeException(); } } What is the result?()
第18题:
BD
BCD
BDE
BCDE
ABCDE
Compilation fails.
第19题:
main
编译失败
main java.lang.RuntimeException: exception
代码运行,但没有输出
第20题:
Throws Exception.
Catch (Exception e).
Throws RuntimeException.
Catch (TestException e).
No code is necessary.
第21题:
Since the method foo() does not catch the exception generated by the method baz(), it must declare the RuntimeException in its throws clause.
A try block cannot be followed by both a catch and a finally block.
An empty catch block is not allowed.
A catch block cannot follow a finally block.
A finally block must always follow one or more catch blocks.
第22题:
第23题:
异常的继承结构:基类为Throwable,Error和Exception继承Throwable,RuntimeException和IOException等继承Exception
非RuntimeException一般是外部错误,其必须被 try{}catch语句块所捕获
Error类体系描述了Java运行系统中的内部错误以及资源耗尽的情形,Error不需要捕捉
RuntimeException体系包括错误的类型转换、数组越界访问和试图访问空指针等等,必须被 try{}catch语句块所捕获