a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 176|回复: 3

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q82.What is the result of attempting to compile and run the following program?/ @, [% v1 O9 p6 A4 E6 H) a
  1. import java.io.*;. |, D) r, I- @) `6 W. {4 O. }
  2. public class OutOut {4 H& M) k* \/ i, a: `4 \0 s0 \+ g
  3. public static void main(String args[]) throws IOException {: L3 e) d  F. m
  4. PrintStream pr = new PrintStream(new FileOutputStream(“outfile”));
- z/ |7 D  s/ m1 f8 t2 u- M  5. System.out = pr;8 F  I" W; X* e  T5 Z. q
  6. System.out.println(“Lets see what I see now??”);6 J8 W" N. Y1 n9 f0 _+ M
  7. }: {# x( Y1 G% S
  8. }) z4 X& r* L* Z9 ]
  [Select one correct answer]$ r. @9 r! R1 O
  a. The code causes a compiler e rror. out is a declared final in System and cannot be assigned to pr.
3 M- Z$ z) @" U  b. The code causes a runtime Exception due the assignment to a final variable.
  [, G3 k" \! N  c. The code compiles and runs success fully. A file called “outfile” is created and “Lets see what I see now??” is printed in the same.
$ Z$ K2 V; y/ x. y  d. The code cause a compiler error. PrintStream is an abstract class
9 V' v+ V- I% B# |/ v; t  Q83.What is the result of attempting to compiler and run the following pieceof code.
" K1 ?6 k  k5 l+ z5 x* c
; w9 s  j* g/ C8 t1 |/ i8 ]9 Y8 |  1. import java.awt.*;
2 o. H- M; N( P" D. E2 H  2. public class TestFrame extends Frame {
3 P/ u" d& G4 n0 L  y% p! Q  3. public TestFrame() {. r. E8 w. K3 o( X$ R
  4. Button one = new Button(“One”);8 V; o1 N) P8 Q
  5. Button two = new Button(“Two”);
回复

使用道具 举报

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

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

</p>  6. Button three = new Button(“Three”);
" l7 g8 F& t- w# t) l/ t$ g8 G, H  7. setLayout(new FlowLayout());. N" {) X+ L3 X7 }  ~+ U3 m$ X. `
  8. add(one);
& i5 c4 l; V9 w5 r! C  9. add(two);
* E  g: W  x. R, e: u7 H: n: t  10. add(three);
! `2 s+ C( @3 C  x# l  11. setSize(1000,1000);+ d, y0 k+ Q2 ^% c
  12. setVisible(true);
5 X% e6 Z! h; s  13. two.setVisible(false);
, I; y& f+ E3 Z8 D$ N) {  14. }* v& r. b0 S, F, l; ]/ U  U
  15. public static void main(String args[]) {
) @: C; b, \  i  16. TestFrame tf = new TestFrame();5 `( M, K0 \+ ~* X6 v- x9 f9 d
  17. }
) v) a! W/ r. z( b- H' f+ \$ |  18. }7 Q" D+ P8 O2 c/ @' F3 j$ l' c
  Select one correct answer
$ y. h/ b+ K* j( m" y& @8 |3 [. Q, Q  a. If the above code runs, the buttons - one and three are laid out in a single row from left to right with a gap in between.; F. H: r$ k6 N! X) }
  b. If the above code runs, the buttons - one and three are laid out in a single row from left to right with no gap in between.
4 g( f# v0 v% X1 \) B/ v: ]  c. Code does not compile - a component can not be hidden after being added to a container.; S( ?5 a% r0 _& n- ?, @  J
  d. Code gets compiled successfully but throws runtime Exception - a component can not be hidden after being added to a container.
" Z& F9 _8 C# \4 Z  {3 v1 g" b& [' u- x4 @. f. [* z) I
  Q84.What is the result of attempting to compile and run the following piece of code?4 \9 X% q" i* U  _
  1. import java.awt.*;
7 A0 k1 x7 X! I  a- j  2. public class TestFrame extends Frame {: N; u) I4 T# T0 {, V
  3. public TestFrame() {
- a( a3 ^; K# S4 E, Y1 s5 R* V  4. CheckboxGroup chg = null;6 R0 z7 ]; |- D: d/ Z5 J
  5. Checkbox ch = new Checkbox(“Test”,true,chg);3 s3 X  Q( b' [5 n
  6. setLayout(new FlowLayout());
: o$ X: B) C3 n3 w" `. b  7. add(ch);
" a9 ^1 c- ~" p  Y  8. pack();
9 z% Z6 W- ^$ u4 p  9. setVisible(true);9 C7 D  r  ]3 C- v; Q' w
  10. }
! q, n: Q" d0 S6 V  11.
; S/ s+ Y/ j7 ?% S  T6 f  12. public static void main(String args[]) {
9 F/ o5 f3 z0 `  13. TestFrame tf = new TestFrame();# t; u  ^& \2 W  K1 P
  14. }
& P+ b  R, @( T7 Z) V; ]3 S  15. }' v; b. o; L) N+ }
  [Select one correct answer]
* k6 {7 i* y0 U* f  a. It will cause a compilation error as the checkbox group is null in the constructor.9 y2 R% p; J1 U
  b. It will compile successfully but throws a runtime exception because the checkbox group is null in the constructor of the check box." \3 z7 @8 J/ o1 O( B; ]" V
  c. It will compile and run successfully. The checkbox appears as a single radio button which is always true1 a4 S6 \. `. O6 K' |, f
  d. It will compile and run successfully. The checkbox bears its original appeareonent can not be hidden after being added to a container.
  H: A; N( Y- G: `4 B% T0 n' q
6 @$ }6 U1 F; P  Q84.What is the result of attempting to compile and run the following piece of code?
8 M6 e9 ]+ L3 T3 g% P  a, ?0 W- p6 s0 U7 m
  1. import java.awt.*;
回复 支持 反对

使用道具 举报

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

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

</p>  2. public class TestFrame extends Frame {
4 [; z5 k0 O6 \7 N$ U; r  3. public TestFrame() {7 o* `2 r3 {, C: v" e
  4. CheckboxGroup chg = null;
: Y+ w! W) H9 |7 D; R- O  5. Checkbox ch = new Checkbox(“Test”,true,chg);
% T, Q/ U. `0 J! w" V5 H  6. setLayout(new FlowLayout());1 w8 |, T, C6 V0 U
  7. add(ch);& r* y* h. z8 I( }1 {* p0 {  ~
  8. pack();3 V+ K+ g* ?7 V$ N% }1 W! [1 G: h# X
  9. setVisible(true);
1 c& L# M  B# [9 z1 y/ }2 _  10. }$ b3 X3 A& i* w" X
  11.
2 g1 b. h1 U! h% v; K  12. public static void main(String args[]) {* L( X; z/ x6 X8 l0 d/ O3 \
  13. TestFrame tf = new TestFrame();3 e% J# ~0 E4 j2 H4 c; U* f- ]3 M
  14. }! X' P! v6 \7 o) ~
  15. }
1 a5 k; O% K" L4 _  [Select one correct answer]
, B) K/ [/ Y$ p$ r+ K  a. It will cause a compilation error as the checkbox group is null in the constructor.
% l. z* M4 a5 ?/ Y8 U1 g* ^/ y  b. It will compile successfully but throws a runtime exception because the checkbox group is null in the constructor of the check box.5 ^! R, |% r3 D  i! a, W
  c. It will compile and run successfully. The checkbox appears as a single radio button which is always true: g# |: J% ^0 g7 w
  d. It will compile and run successfully. The checkbox bears its original appeareonent can not be hidden after being added to a container.
1 _2 T' {. T8 [( R. R3 m# p' I) `% e. Y1 s
  Q84.What is the result of attempting to compile and run the following piece of code?
. S/ e) F! E! m$ _3 M* p  1. import java.awt.*;
) k2 Y( t, e0 a, \7 y  2. public class TestFrame extends Frame {
3 K* @% q$ R* d( @5 d# Q  3. public TestFrame() {
- \2 a& J3 \$ T5 o( _9 I% w' D  4. CheckboxGroup chg = null;
; h2 z# n4 D" C$ S  5. Checkbox ch = new Checkbox(“Test”,true,chg);8 _) {6 p# _) x7 o! @* x3 k- E% n9 w
  6. setLayout(new FlowLayout());
2 [7 ~# m; \  X; T$ i  7. add(ch);
" T  Z8 M5 L: c* ]$ v! f  8. pack();
" E7 d& L3 d) n5 c. f& R  9. setVisible(true);
, m! }2 K8 h( P1 ^( A  10. }
0 ~! N# f+ N. `0 W. N  11.
+ X) r7 g$ E" W" j  12. public static void main(String args[]) {
2 s4 U% b" E/ g8 Z6 k: g  13. TestFrame tf = new TestFrame();
( Z3 _8 j( |5 l  C+ m# U  14. }5 X/ @; b" C# H
  15. }
$ v; a& o+ ^+ }- C+ x. c7 o* b+ e  [Select one correct answer]; o! G2 D, t+ D  @) b
  a. It will cause a compilation error as the checkbox group is null in the constructor.
. Z! Q+ _$ g* e# w& ^  b. It will compile successfully but throws a runtime exception because the checkbox group is null in the constructor of the check box.# t/ D2 `) h& f+ p3 }  {8 ^

1 X8 q3 |. t6 @, V- v- D  c. It will compile and run successfully. The checkbox appears as a single radio button which is always true
回复 支持 反对

使用道具 举报

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

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

</p>  d. It will compile and run successfully. The checkbox bears its original appeareonent can not be hidden after being added to a container.
6 W5 m8 C4 v' W1 |% m' k
4 F- F( M  d4 B1 X, o; A/ }+ s+ ]  Q84.What is the result of attempting to compile and run the following piece of code?) i" U' m" S: w+ l$ A" p9 s$ b* k" P
  1. import java.awt.*;* E7 M+ g) ^: U" ?
  2. public class TestFrame extends Frame {8 z9 ~$ t: f+ E* R/ E4 k9 U+ }8 e
  3. public TestFrame() {* o# w$ V2 O* W1 X* f$ t* Y  c
  4. CheckboxGroup chg = null;- T& F- d! x% V' g% C9 {
  5. Checkbox ch = new Checkbox(“Test”,true,chg);3 y+ d8 o3 ^, H$ h% N  ~- i
  6. setLayout(new FlowLayout());" k; A" C* K+ c' \& m6 b1 Q
  7. add(ch);, h+ E4 b% e. v( X1 A
  8. pack();
' K+ a4 k* f! _% i  j% [' F3 h  9. setVisible(true);8 K0 V: `9 V" \2 l' b
  10. }, h* k3 U- Y- d. z
  11.! T: u# z# O4 g7 v1 j1 X6 z: ~
  12. public static void main(String args[]) {
9 m# v/ O3 p9 @% s* D  13. TestFrame tf = new TestFrame();
9 O) m: h7 V1 O9 u  14. }. q: h3 z  P7 i
  15. }+ L. f9 I$ y1 E) H
  [Select one correct answer]3 x' j. Z% ~+ }6 _
  a. It will cause a compilation error as the checkbox group is null in the constructor.! W7 E5 I& v( E7 l% c9 j/ b
  b. It will compile successfully but throws a runtime exception because the checkbox group is null in the constructor of the check box.5 o. X0 p. Q' a0 C$ z
  c. It will compile and run successfully. The checkbox appears as a single radio button which is always true0 @# |) [! {* T1 u2 L) w' p  z8 Z. U( o
  d. It will compile and run successfully. The checkbox bears its original appearence and does not appear as a radio button. % A. v4 C) [: k. @. s% P( c

. ~/ M' j! t- j' Q7 e  U8 O- ?  82. a
4 \7 C' k) s( Q, Y( U  s  83. a8 y6 ~- G" _0 A4 P! _
  84. d
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-21 22:58 , Processed in 0.217082 second(s), 27 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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