SCJP真题库更新19

QUESTION 91

Given a method that must ensure that its parameter is not null:

 

What, inserted at line 12, is the appropriate way to handle a null value?

A. assert value = = null;

B. assert value != null, "value is null";

C. if (value = = null) {

throw new AssertionException("value is null");

}

D. if (value = = null) {

throw  new IllegalArgumentException("value is null");

}

 

 

Answer: ( D )

A      不要用断言对公共方法的参数进行判断

B      同上

C     没有AssertionException这个类; AssertionError继承自Error,处理和捕获 error是没有意义的

D      OK 抛出参数错误的异常.

 

 

QUESTION 92

Place the correct Code in the Code Sample to achieve the expected results.

Expected results:

Output: 1 2 4 8 16 32

Code Sample

 

 Answer: (  )

for (int x : y){

 

QUESTION 93

Given:

 

Which two will produce an AssertionError? (Choose two.)

A. java test

B. java -ea test   

C. java test file1

D. java -ea test file1

E. java -ea test file1 file2   

F. java –ea : test test file1

 

 

Answer: ( B, E )

 

QUESTION 94

Given:

 

Which statement is true if a ResourceException is thrown on line 86? 

A. Line 92 will not execute.

B. The connection will not be retrieved in line 85.

C. The resource connection will not be closed on line 88.              

D. The enclosing method will throw an exception to its caller.

 

 

Answer: ( C )

 

QUESTION 95

Assuming that the serializeBanana() and the deserializeBanana() methods will correctly use Java serialization and given:

What is the result? 

A. restore 400

B. restore 403

C. restore 453   

D. Compilation fails.

E. An exception is thrown at runtime.

 

 

Answer: ( C )

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值