SCJP真题库更新18

QUESTION 86

Given:

 

What is the result? 

A.    A, B, C

B.     B, C, A

C.     Compilation fails

D.    The code runs with no output

E.    An exception is thrown at runtime

 

 

Answer: ( B )

LinkedList有顺序性,

 

QUESTION 87

Given

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 )

16行抛出Error, 没有捕获。    

  Error Exception都是Throwable类的子类。Throwable 类是 Java 语言中所有错误或异常的超类。只有当对象是此类(或其子类之一)的实例时,才能通过 Java 虚拟机或者 Java throw 语句抛出。类似地,只有此类或其子类之一才可以是 catch 子句中的参数类型。

 

QUESTION 88

Given:

 

Which three, will make code on 37 execute

A. The instance gets garbage collected.

B. The code on line 33 throws an exception.

C. The code on line 35 throws an exception.

D. The code on line 31 throws an exception.

E. The code on line 33 executes successfully.

 

 

Answer: ( B, C , E)

 

 

QUESTION 89

Given:

What is the result?

A. Compilation fails

B. pi is bigger than 3.

C. An exception occurs at runtime.

D. pi is bigger than 3. Have a nice day.

E. pi is not bigger than 3. Have a nice day.

 

 

Answer: ( A )

finally子句只能与try…catch…配合使用,而不能与if...else…配合使用

 

 

 

 

 

 

QUESTION 90

Given:

 

Which code, inserted at line 16 will cause a java.lang.ClassCastException? 

A. Alpha a = x;

B. Foo f = (Delta)x;

C. Foo f = (Alpha)x;

D. Beta b = (Beta)(Alpha)x;

 

 

Answer: ( B )

编译时父类型对象和子类型对象相互的强制转换不会发生任何异常。但是,运行时将父类的对象强制转换为子类别的对象时会抛出java.lang.ClassCastException异常。对于本题,运行时(Delta)x会抛出java.lang.ClassCastException异常。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值