云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > Java复习题2及答案

Java复习题2及答案

  • 62 次阅读
  • 3 次下载
  • 2025/12/12 4:12:38

}finally{

System.out.print(\ } } }

public static void main(String []args) {

try{

aMethod(0);

}catch(Exception ex){

System.out.print(\ }

System.out.print(\ }

a) finally

exception in main finished

b) exception in main finally c) finally finished d) finished

exception in main finally

45、下面的异常处理代码的输出结果是()。 try{

int result = 6/0;

System.out.print(\,\ } catch(ArithmeticException e1) {

System.out.print(\异常,\ throw new Exception(); } catch(Exception e2) {

System.out.print(\异常,\ } finally {

System.out.print(\ }

A. 程序错误

B. ArithmeticException异常,finally

C. ArithmeticException异常, Exception异常, finally

D. try, ArithmeticException异常, Exception异常, finally

46、下列代码的输出结果是()。 public class Example {

String str = new String(\ char[] ch = {'a','b','c'};

public static void main(String[] args) { Example ex=new Example(); ex.change(ex.str,ex.ch);

System.out.print(ex.str+\ System.out.println(ex.ch); }

public void change(String str,char ch[]){ str=\ ch[0]='g'; } }

A. good and abc B. good and gbc C. test ok and abc D. test ok and gbc

47、阅读下面代码,将会输出()。 public class Testa {

Integer a = new Integer(10); Integer b = new Integer(10);

public static void main (String[ ] args){ Testa testA = new Testa(); if (testA.a==testA.b){

System.out.print(\很\ }

if (testA.a.equals(testA.b)){ System.out.print(\好\ } } }

48、关于Java的继承,下面说法错误的是()。(选择两项) A. 接口可以继承接口 B. 子类不可以继承父类的私有属性和私有方法 C. 所有类都是java.lang.Object的子类,但是不可以这样写:public class

Earth extends Object{}

D. 一个类不可以继承(extends)另一个类,同时又实现(implements)一个接口

49、阅读下面的代码,正确的说法是()。(选择两项) class Foo {

int num;

Baz comp = new Baz();

A. B. C. D. E.

50、try {}里有一个return语句,那么紧跟在这个try后的finally{}里的代码会不会被

执行,什么时候被执行?

A. 不会执行 B. 会执行,在return前执行 C. 会执行,在return后执行 D. 会执行,可能在return前执行,也可能在return后执行

}

class Bar {

boolean flag; }

class Baz extends Foo { Bar thing = new Bar(); double limit; }

Bar是Baz子类 Foo 包含 Bar Baz是Foo子类 Foo是Baz子类 Baz包含Bar

搜索更多关于: Java复习题2及答案 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

}finally{ System.out.print(\ } } } public static void main(String []args) { try{ aMethod(0); }catch(Exception ex){ System.out.print(\ } System.out.print(\ } a) finally exception in main finished b) exception in main finally c) finally finished d) finished exception in main final

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com