下载此文档

JAVA基础面试题.doc


文档分类:IT计算机 | 页数:约13页 举报非法文档有奖
1/13
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/13 下载此文档
文档列表 文档介绍
JAVA语言基础笔试题-2
翁舟洋 2012-6-8
Question 1
Given:
{
12. public void process() { (“A “)} }
13. class B extends A {
14. public void process() throws RuntimeException {
15. ();
16. if (true) throw new RuntimeException();
17. (“B”)
}}
18. public static void main(String[] args) {
19. try { ((A)new B()).process(); }
20. catch (Exception e) { (“Exception “)}
21. }
What is the result?
A. Exception
B. A Exception
C. A Exception B
D. A B Exception
E. Compilation fails because of an error in line 14.
F. Compilation fails because of an error in line 19.
答案:B
考点:异常的抛出
说明:任何一个方法,将默认在其签名上写上 throws RuntimeException,此处不认为子类重写方法抛出了比父类对应方法更多的异常。
Question 2
Given:
11. static classA
{
12. void process() throws Exception { throw new Exception(); }
13. }
14. static class B extends A {
15. void process() { (“B”)}
16. }
17. public static void main(String[] args) {
a=new B();
19. ();
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.
答案:A
考点:继承,重写,异常的抛出,
说明:父类A变量指向子类B的对象,调用B中的process()方法
Question 3
Given:
11. static classA {
12. void process() throws Exception { throw new Exception(); }
13. }
14. static class B extends A {
15. void process() { (“B”);
16. }
17. public static void main(String[] args) {
18. new B().process();
19. }
What is the result?
A. B
B. The code runs with no output.
C. Compilation fails because of an error in line 12.
D. Compilation fails because of an error in line 15.
E. Compilation fails because of an error in line 18.
答案:
考点:
说明:
Question 4
Given:
84. try {
85. ResourceConnection con = ();
86. R

JAVA基础面试题 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数13
  • 收藏数0 收藏
  • 顶次数0
  • 上传人zbfc1172
  • 文件大小99 KB
  • 时间2018-09-12
最近更新