a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 86|回复: 1

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q10.In the following applet, how many buttons will be displayed?6 V. u/ z) B/ ?# P) W
  1. import java.applet.*;
- c# g8 S7 \" G  2. import java.awt.*;. M7 N0 T* A, _
  3. public class Q16 extends Applet {3 t# g& i# Y( D1 J
  4. Button okButton = new Button(“Ok”);
0 ~5 p* d: ]( O9 ~  5. public void init() {% m+ ^# R  B5 P% y4 P" ~1 U
  6. add(okButton);
  j$ ]5 \. f8 ]  7. add(okButton);
5 p& U; z7 V7 N6 q7 \5 d3 N  8. add(okButton);
* I  x8 m) R9 q  W, }  9. add(okButton);
' l' S' c' \* `, B: u' @) K  10. add(new Button(“Cancel”));
) d5 k9 H; y: P5 Q" y+ K- z# F- L  14. add(new Button(“Cancel”));1 U6 F  E# w7 t9 Z
  15. add(new Button(“Cancel”));
$ p, N9 W8 E) \, ~  16. add(new Button(“Cancel”));# K/ S# `' P5 P1 }$ ~) o3 T
  18. setSize(300,300);
/ G3 J5 I0 C4 B  X) F* g# X  19. }; Z' L3 n7 i  v' ?& N
  20. }# G& N: _, u# L. H: ^
  a. 1 Button with label “Ok” and 1 Button with label “Cancel”.( Y7 Q6 b' u7 k5 Z) {
  b. 1 Button with label “Ok” and 4 Buttons with label “Cancel”.5 E  H) n1 S8 @0 z8 @
  c. 4 Buttons with label “Ok” and 1 Button with label “Cancel”.
( I7 s3 Y1 G" e' F( S  d. 4 Buttons with label “Ok” and 4 Buttons with label “Cancel”.
9 Y3 w* |/ d4 r  Q11.What is the output of the following program?4 s' [7 m1 y) C) I: h& f9 c  O
  1. class Test {
6 c- h, B" r7 z$ Z- n  2. void show() {
/ H5 K3 N& D0 {# H$ B9 k  3. System.out.println(“non-static method in Test”);- H: M+ U2 v( \2 @
  4. }; K4 I7 s  a$ Q$ @& b* Z
  5. }
6 u* o& A. Q# b& {' E- c  6. public class Q3 extends Test {' Q0 m* s+ `2 z3 I
  7. static void show() {
+ P% F0 C/ m& O2 J% R  8. System.out.println(“Overridden non-static method in Q3”);
$ l6 @( s) ?0 c7 e4 S8 I- R  9. }
  n7 O4 A3 b  P" x3 X: ]1 c  10. public static void main(String[] args) {
回复

使用道具 举报

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

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

</p>  11. Q3 a = new Q3();
3 ~4 T+ M* p# N- R  12. }
- Y/ |* |8 E" o, z) ]( ~2 T  13 }2 Q4 r) H+ Z) M; X# [" {1 ?
  a. Compilation error at line 2.# p6 ]/ B3 w+ {$ M& c" _
  b. Compilation error at line 7.
3 {* y# C/ K1 P! D  c. No compilation error, but runtime exception at line 2.
9 j5 F! L. r+ V$ ]0 Q8 F/ s  d. No compilation error, but runtime exception at line 7.
, y! q+ \  d. n# b$ B  Q12.What will happen if you compile/run the following code?
6 F* T# w' l4 `  T# ~* i  1. public class Q21 {/ ]" ?) b5 V) B, d% X
  2. int maxElements;  t2 X4 k/ K+ b% I
  3. void Q21() {6 h2 J1 w" {+ U8 f6 o0 Q& E6 d* ^# b
  4. maxElements = 100;) ^3 m0 \/ M, H' U+ S
  5. System.out.println(maxElements);
, O5 w! i. U0 x7 f/ U- a  6. }8 b. ]7 ?* `( n
  7. Q21(int i) {) B* I- B( \/ A% O, d% z5 D
  8. maxElements = i;) K0 G8 ?3 f; U  _  m3 G
  9. System.out.println(maxElements);
) z: _! o. y3 h/ w" L7 A1 J2 \( V  10. }! c% C) C( I5 N) p8 V9 t9 G
  11. public static void main(String[] args) {/ `+ y' [( p: ^/ B0 h1 k) [
  12. Q21 a = new Q21();
4 @+ b+ j  q$ w, Z  13. Q21 b = new Q21(999);5 i+ ]8 e, H3 a; l$ a, `" K
  14.: r/ m2 [( M- ^) W" r1 W
  15. }7 D2 ~* b# F. I1 A, V
  16. }
1 R3 f4 Z7 u- H" E  a. Prints 100 and 999.
  ^3 y: Y; `) T/ j7 |9 {+ [  b. Prints 999 and 100.
/ g! W# o0 A" `* n: o' f6 m  c. Compilation error at line 2, variable maxElements was not initialized.
& }1 [' U; X$ k. i: R  d. Compilation error at line 12.
# ~* I% J8 i1 n  10. b
4 l9 z" i( g! V$ j3 K0 p7 e  11. b
( C6 b- r! ~' B! w; b# D8 I  12. d
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-18 01:45 , Processed in 0.272226 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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