Given:
11. static classA {
12. void process() throws Exception { throw new Exception(); }
13. }
14. static class B extends A {
15. void process() { System.out.println(”B “); }
16. }
17. public static void main(String[] args) {
18.A a=new B();
19. a.process();
20.}
What is the result?
A. B
B. The code runs with no output.
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 15.
E. Compilation fails because of an error in line 18.
F. Compilation fails because of an error in line 19.答案是选F,为什么呢?- -
解决方案 »
- 用java开发桌面软件,有什么好的控件库吗?
- 如何从C++快速转java
- 请教 java中如何输出一个变量的反值?
- 麻雀虽小,五脏俱全:新新手,IP和Socket小知识
- 有关覆盖超类方法的问题
- new 的优先级高,还是点的优先级高?????
- 在java代码中如何运行一个外部的程序?
- 在java 中 如何定义一个可以存储300个字符的字符串
- 使用jspsmart下载文件时,报错java.lang.IllegalStateException: getOutputStream() has already been called for this response
- jb7的控件设计问题
- 内存数据实时存储
- 关于super调用一个有些弱智的问题,大家别笑哈。。
因为A定义的process方法抛出异常,但是你没有捕获。
加上try catch语句就ok了。