Question 79
Given:
11. static void test() throws Error {
12. if (true) throw new AssertionError();
13. System.out.print(!±test !°)
14. }
15. public static void main(String[] args) {
16. try { test(); }
17. catch (Exception ex) { System.out.print(!±exception !°);
18. System.out.print(!±elld !°)
19. } What is the result?
A. end
B. Compilation fails.
C. exception end
D. exception test end
E. A Throwable is thrown by main.
F. An Exception is thrown by main.
Answer: E
Given:
11. static void test() throws Error {
12. if (true) throw new AssertionError();
13. System.out.print(!±test !°)
14. }
15. public static void main(String[] args) {
16. try { test(); }
17. catch (Exception ex) { System.out.print(!±exception !°);
18. System.out.print(!±elld !°)
19. } What is the result?
A. end
B. Compilation fails.
C. exception end
D. exception test end
E. A Throwable is thrown by main.
F. An Exception is thrown by main.
Answer: E
解决方案 »
- 分解一个字符串到数组中……
- 关于javabean
- Myeclipse8 swing组件怎样从源代码生成可视化form
- Hi,老紫竹,pls help ;use State.java read out the actual state from the split.java!!!!!!!!!!
- 请问数字转字符串的问题 如 32 转为 '0032'
- jacob如何操作word文档的页眉?
- 常见人争论几个常用Collection类的效率问题,这次我做了个实验,欢迎进来讨论
- cvsnt-2.5.01和eclipse的配置问题。!!
- Java平台程序与Windows平台程序有接口吗?
- 关于http://developer.java.sun.com
- 关于java中static关键字的使用
- JavaFX中.fx文件和java文件之间如何传值?
问题一:我在eclipse运行了以后,错误提示是:
Exception in thread "main" java.lang.AssertionError
at Test.test(Test.java:3)
at Test.main(Test.java:8)
是Exception被抛出而不是Throwable啊!!所以怎么会是E呢?
try { test(); }
catch (Exception ex) { System.out.print(!±exception !°);
是抓不到该AssertionError的,而是直接抛给了JVM.
因而是E.
但是我在CMD下测试,javac 命令没有错误,java 命令就提示:
Exception in thread "main" java.lang.NoClassDefFoundError: Test{我的测试类类名}如何理解这句话里的“Exception”而不是“throwable”谢谢
可是你扔出的不是Error吗
强烈反对此种宣传,唉,本十分仰慕java2000_net的,可是回复了我的帖子全是这个广告,太让我失望了!!!!!!!!!!!!