a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 116|回复: 1

[考试试题] JAVA认证历年真题:310-025精选题(12)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
34. Given the following method body:
% I0 s) z% A0 ~/ p% P{- |. v! w4 {! G! p7 U' X0 S
if (sometest()) {
9 h! R+ z9 J$ G6 Xunsafe();! ]/ e2 a0 H7 d. }7 |
}
4 s1 T& V5 N  O3 q( k+ Oelse {
9 D6 ~3 f+ }9 z, K9 csafe();$ v$ C6 }* K, P8 q; k. I/ ?
}4 o; Q& k) V6 m+ V8 N
}
$ d9 I( a9 @) }8 O8 qThe method "unsafe" might throw an IOException (which is not a subclass of RunTimeException). Which correctly completes the method of declaration when added at line one?
6 b: [$ m  V# L9 R" U5 QA. public void methodName() throws Exception5 q# a5 M# k* [5 v
B. public void methodname()
3 r% b( N: Y' o8 `# x# QC. public void methodName() throw IOException
5 u0 Q. E+ h" a+ n9 C! l5 ]D. public void methodName() throws IOException
, o4 m$ o0 p( \/ E3 R- D0 FE. public IOException methodName()
3 f+ ~. n5 \/ i& vAD.
7 H+ V) F  u* _. r, k& T7 N4 B8 O35. What would be the result of attempting to compile and run the following piece of code?
  Z! Y/ \0 _  m' k- e+ N8 x
5 t& p8 r/ ~) j$ cpublic class Test {
7 a2 `' ^  n0 S& N8 h& y/ Z' Wstatic int x;( S3 b3 H+ H- {
public static void main(String args[]){: ?4 s* W5 [7 q
System.out.println("Value is " + x);
/ e' x3 b  i/ K}% l7 Y: \0 h- a5 Y! I
}
回复

使用道具 举报

 楼主| 发表于 2012-8-4 12:33:17 | 显示全部楼层

JAVA认证历年真题:310-025精选题(12)

</p>A. The output "Value is 0" is printed.
  F! T) V9 E- e5 A/ {* o1 G- y  gB. An object of type NullPointerException is thrown.3 b4 ?  |) Q8 `; r& H- ]
C. An "illegal array declaration syntax" compiler error occurs.$ @/ `3 m! n0 M1 w
D. A "possible reference before assignment" compiler error occurs.
. S! Y0 b3 R$ z  r, ?) P5 DE. An object of type ArrayIndexOutOfBoundsException is thrown.
3 D/ ]" [) M" R! u7 `6 {A.
- ?8 T& W1 b5 w! b0 g36. What would be the result of attempting to compile and run the following piece of code?$ |6 ]/ a9 O! f) Y) F& g
public class Test {
, d2 g1 _2 H# [public int x;
) C% h$ [% m  S+ f8 F0 wpublic static void main(String args[]){& I9 k$ C3 D' I! S! |0 S% g( Q
System.out.println("Value is " + x);
' r$ [; O- k# w: R2 J+ g}
" T8 ~) R. t0 c: P}
; b* p3 x) Q* @6 n" ^A. The output "Value is 0" is printed.3 R  W# h0 H) N5 S
B. Non-static variable x cannot be referenced from a static context.., @' K) h! V- \
C. An "illegal array declaration syntax" compiler error occurs.( p1 L1 \# O# R3 X; m3 e- O
D. A "possible reference before assignment" compiler error occurs.
: i! P+ D& t0 u7 t/ H8 w$ n9 eE. An object of type ArrayIndexOutOfBoundsException is thrown.
/ Z" a! C7 S  m0 B2 `" S: J% U5 Q8 E* AB.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-6-2 14:19 , Processed in 0.189040 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表