Java认证模考试题(八)

文章作者 100test 发表时间 2007:03:14 17:02:44
来源 100Test.Com百考试题网


Question: 41


Given the following code:

public void fun ()

{

int i.

try

{

i=System.in.read ().

System.out.println(Location 1).

} catch (IOException e) {

System.out.println(Location 2).

} finally {

System.out.println(Location 3).

}

System.out.println(Location 4).

}

If an IOException occurs, what will be printed?


A. Location 1

B. Location 2

C. Location 3

D. Location 4

Explanation:


When an IOException occurs the Location 1 is skipped. Fist the exception is caught and the Location 2 is printed. Then the Location 3 in the block of finally is printed. Finally, the Location 4 is printed.

Correct Answer: B,C,D 41 of 60


Question: 42


If the method func() is allowed to throw out the IOException, which declaration of this method can used?


A. public int func(int i)

B. public int func(int i) throw IOException

C. public int func(int i) throw Exception

D. public int func(int i) throws IOException

E. public int func(int i) throws Exception

Explanation:


The throws keyword should be used when declaration of a method. In the declaration IOException and its superclass Exception can be used.

Correct Answer: D,E 42 of 60



相关文章


Java认证模考试题(九)
了解Java密码扩展的基础
Java认证模考试题(十)
java基础--JAVA字符集
Java认证模考试题(八)
Java认证模考试题(七)
JAVA基础:Java启动器如何查找类
Java程序设计知识与技能(五)
LineNumberReader提供更好的出错消息
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛