a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 276|回复: 1

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q85.What is the result of attempting to compile and run the following program?2 C- k" n8 A8 k6 p
  1. public class Test {! b  `1 S& p0 G- {$ h' _( ?. T( k
  2. private int i = j;
) R+ u9 w- Y8 a3 x0 V8 j  3. private int j = 10;
4 f+ K/ _5 [, n/ j  4.: ?% d7 Q- Y. R
  5. public static void main(String args[]) {0 q( m' Y3 L7 }4 g0 P0 _4 L
  6. System.out.println((new Test()).i);
% u; }% h+ F! f8 n& u7 w* l# `  7. }
. [9 |' a0 F: O4 P; H3 p  8. }
! r9 i# [- [4 f3 f( S  [Select one correct answer]
$ ^; x- E: \8 X% a/ V9 c' p4 K  a. Compiler error complaining about access restriction of private variables of Test.! m# d6 A8 s7 [/ ^
  b. Compiler error complaining about forward referencing.
" Q; w  O+ C3 b  c. No error - The output is 0;: u9 j* B  e, s4 c
  d. No error - The output is 10;# B+ D4 v: `1 [; w0 j' Y" E
  Q86.What is the result of attempting to compile and run the following program
0 N7 w' G+ g! u  b. h) m9 H9 A  1. public class A {! }: _+ a# T& L5 R  l& I" N
  2. private void method1() throws Exception {$ G8 U0 b6 G. ]* \% s
  3. throw new RuntimeException();
. M3 [; H% p) r' ^  4. }: o0 v9 U7 b. r
  6. public void method2() {1 [! |2 l& r; K6 i4 g' |
  7. try {
& P& z! y1 `* u3 X% m/ H  8. method1();
( m* S- S! F  c) G  9. } catch(RuntimeException e) {1 E9 G1 [$ x- z, {2 L) v
  10. System.out.println(“Caught Runtime Exception”);
( q9 o  t, L* a/ x( s  11. } catch(Exception e) {' L, m- a* X( z
  12. System.out.println(“Caught Exception”);2 a7 b; }  u8 M/ U3 e4 i+ c$ r/ L8 I
  13. }
8 x: d, S! W* K, H4 p) K, A/ Z9 j$ w' T4 C7 h
  14. }
回复

使用道具 举报

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

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

</p>  15. public static void main(String args[]) {
- H- s/ F& U( o* O) `" D/ B' D  16. A a = new A();
9 x7 R0 W" [: p2 e* R; q! c  17. a.method2();
  X1 g) w3 |) k* a  I9 B  18. }1 r4 ^! {4 d. v/ v
  19. }( W  R3 s9 q& `- M  |$ j+ D
  [Select one correct answer]
) U6 o- H& _# @; @  a. It will not compile.# n! z  _# T! k- E( _( L' }
  b. It will compile and show - “Caught Exception”.
& g$ }8 x3 K% N. n. P) x  c. It will compile and show - “Caught Runtime Exception”.
, w7 d% I# r7 U- I* A1 b7 C  d. It will compile and show both the messages one after another in the order they appear.6 K$ n- u$ j( l6 p) P
  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.) c' k8 P- c7 w6 b# q
  a. The above expression will cause a '0' appear on the command line.
5 D9 P  V) w% G, l- }  b. It will throw a N ullPointerException.. _" L3 x+ U4 X5 z" L% Y
  c. It will cause a nk line to appear.! y* p* E7 M) H3 g
  d. It will cause a comilation error at line 1 due to length.
4 a; v) @$ N3 H0 t/ s  85. b2 r: t" ?8 d0 D  k% g2 f& }5 ?
  86. c
0 x/ B3 ?2 T5 q6 i; i  87. a
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-22 05:28 , Processed in 0.221670 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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