a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 278|回复: 1

[考试试题] 2011年JAVA认证模拟题第二阶段(29)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q85.What is the result of attempting to compile and run the following program?0 [* b, l; y8 m7 e6 @& }1 r
  1. public class Test {/ w2 @$ b# u' e+ X, ?5 P, }; O7 N
  2. private int i = j;
2 v5 [) g% L! M0 S6 O  3. private int j = 10;
. ^' Y0 P' ?  J4 a  4.3 p# K# I. ]* s" T& t" W) F; L2 V
  5. public static void main(String args[]) {- G7 D' w  R" q, D2 K7 F7 A2 k; l
  6. System.out.println((new Test()).i);* Q% p# c/ S  k( w- z: O1 y: ^
  7. }
# h8 R$ T1 b" U. Q, k+ a* M+ t  8. }
7 J  z8 N: A' R+ @# l8 t% r/ j  [Select one correct answer]
% A& S; W' f% P) k+ }4 P  a. Compiler error complaining about access restriction of private variables of Test.
2 x+ G4 M( w  I7 Q0 c7 c  b. Compiler error complaining about forward referencing.
% O' f6 |9 T- m* H- J) `5 m6 Q  c. No error - The output is 0;, n3 D) I$ ?8 W% K. @
  d. No error - The output is 10;
6 g7 v# u7 a* d: b$ ?1 I" v# b2 u  Q86.What is the result of attempting to compile and run the following program
  C0 v! @. X& ~/ q" x  1. public class A {
4 t4 ~) a6 [- n5 `  2. private void method1() throws Exception {" @, @& f9 r! I
  3. throw new RuntimeException();0 q% |- M" s, e1 f, k2 G3 ]: C) d
  4. }
0 f& A7 ?- t/ O. V& k( t  6. public void method2() {% X8 n" f" y4 }9 _
  7. try {% |0 q( ]% C. z% f$ G$ v
  8. method1();2 a2 b( J# o9 R- i4 I$ n
  9. } catch(RuntimeException e) {5 _; X8 J( F7 w" |9 E7 _* U
  10. System.out.println(“Caught Runtime Exception”);
; n1 P) J; l$ {& b1 O  11. } catch(Exception e) {- |; G* [7 |0 E' f8 i
  12. System.out.println(“Caught Exception”);
" |' \' J( n% B1 f  13. }1 _8 @. d( v7 N. y' i7 K+ P2 j6 h
8 K. H5 k; m! U! {
  14. }
回复

使用道具 举报

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

2011年JAVA认证模拟题第二阶段(29)

</p>  15. public static void main(String args[]) {
: o% |3 w" i$ [6 O" P  16. A a = new A();' o& d+ B( Z: W/ i. G
  17. a.method2();
% p" \$ w8 F: I4 A/ F9 h6 e6 T4 A  18. }, y! Y0 D+ ~$ Y8 c/ U: ?
  19. }
/ h' L1 _' A9 T! l3 a: a8 r3 \8 c/ Q  [Select one correct answer]! V2 y: L% o' I# U" @
  a. It will not compile.5 j' ~& d% N% m: D$ J6 e9 I/ _
  b. It will compile and show - “Caught Exception”.8 I1 {; m4 z& F# w. W) N; H
  c. It will compile and show - “Caught Runtime Exception”.7 v1 w% |, N& f
  d. It will compile and show both the messages one after another in the order they appear.8 Q. P  G$ m! U, C* e; i1 [
  Q87.Assume that Cat is a class and String[] args is the argument passed to the public static void main(String args[]) method of the class. The class is executed with the following command line string c;\somedirectory> java Cat An expression in the main method is as follows 1. System.out.println(args.length);What is the result of attempting to compile and run the snipped.% L' V' l8 _! `8 Q/ a; @# m
  a. The above expression will cause a '0' appear on the command line.
4 H! w4 S2 ?5 ]: I% S9 K, \4 ^  b. It will throw a N ullPointerException.
: I6 F+ e' C, b  c. It will cause a nk line to appear.. e: V5 r- o( T4 @& [
  d. It will cause a comilation error at line 1 due to length.$ d5 I  f+ D; h0 O0 g: f. y. s
  85. b
$ ~" V  h2 C; l9 }  86. c
! r0 ?, s5 C  t6 A3 s  87. a
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-3 06:08 , Processed in 0.230324 second(s), 24 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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