a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 108|回复: 1

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q22.Assume the the class AcLis implements the ActionListener interface. The code fragment below constructs a button ande gives it four action listeners. When the button is pressed, which action listener is the first to get its actionPerformed() method invoked?
- U) g$ r( D) ~( E+ s7 ]8 o7 W  1. Button btn = new Button(“Hello”);7 j! p  q8 D( p& {3 L) L% p7 Z# B
  2. AcLis a1 = new AcLis();
2 v  O, z  i/ k" ]6 z5 [  a  I+ M  3. AcLis a2 = new AcLis();
: v% q5 ^# a% w  4. AcLis a3 = new AcLis();, j2 T' `) Z4 N8 W& K' y
  5. btn.addActionListener(a1);8 ]0 i2 D7 y7 ]+ n
  6. btn.addActionListener(a2);' l  T1 J! h/ o; I5 K
  7. btn.addActionListener(a3);$ M, T, u: W7 F+ G+ F& `
  8. btn.removeActionListener(a2);
7 P, e: f$ c+ X7 J  9. btn.removeActionListener(a3);- j& ]' @5 j( b, K" X
  10. btn.addActionListener(a3);
* ~/ S; ^" h0 {% T5 o" u$ l5 L  11. btn.addActionListener(a2);
0 F( V7 t- m9 ?( ~: o5 R# j  a. a1 gets its actionPerformed() method invoked first.4 l9 X1 v* ^0 @
  b. a2 gets its actionPerformed() method invoked first.
3 ^9 N9 }* m4 u& M; ^$ Q  c. a3 gets its actionPerformed() method invoked first.$ g# M6 j- ^4 h0 X5 z, e
  d. It is impossible to know which listener will be first.& M5 ?$ q$ m* O, ~& }% e
  Q23.Which statement or statements are true about the code listed below?
5 T0 Z  Y: d0 A! I4 |! U$ f  1. public class MyTextArea extends TextArea {/ N+ t* @/ Y5 s4 p) T: }1 h5 y7 x/ n
  2. public MyTextArea(int nrows, int ncols) {, z# m! Z% h# W; Z8 Y1 h- b( q
  3. enableEvents(AWTEvent.TEXT_EVENT_MASK);1 y1 S0 u2 x* {
  4. }3 [1 V- r8 B# ?9 t" E, Z
  5. public void processTextEvent(TextEvent te) {
, {+ @& F! G, \) l8 F6 p  c( x7 w- w4 k
  6. System.out.println(“Processing a text event”);
回复

使用道具 举报

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

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

</p>  7. }) D6 l9 G( ]+ h
  8. }. B( ~, I* V+ A" I8 m) T$ S
  a. The source code must appear in a file called MyTextArea.java.
  j8 Q; j/ ~" x& B" T$ P0 F  b. Between lines 2 and 3, a call should be made to super(nrows,ncols) so that the next component will have the correct size.) F' s' k. d9 g1 X2 {. I. L; L. r( @
  c. Between lines 6 and 7, the following code should appear “return true;”
  I1 d( P& \" n" R  d. Between lines 6 and 7, the following code should appear “super.processTextEvent(te);”
* `- l- x% ^6 `% w3 Q  Q24.Which statement or statements are true about the code fragment listed below? (HINT The ActionListener and ItemListener interface each define a single method.)" H/ A8 s! r6 D7 T6 M1 m! j. t
  1. class MyListener implements ActionListener, ItemListener {
- v1 q2 j2 D5 S% _6 d  2. public void actionPerformed(ActionEvent e) {
, B  O) z. o+ z, G0 S  3. System.out.println(“Action.”);- V0 r9 B: D. ~: l; o
  4. }
' j. S/ [& H. v$ I2 _8 e! s- Z  5. public void itemStateChanged(ItemEvent ie) {
% e( G) F  V; L  6. System.out.println(“Item.”);) d( v5 T; ^0 k. Z
  7. }* |$ V* ?4 D- C+ [
  8. }. E( u" v' a3 b( O+ p1 `% W7 X
  a. The code compiles without error.9 w' q3 K6 j, ]1 @0 j' t( c4 h0 h# B
  b. The code generates a compiler error at line 1.: H$ x) ^3 e' i  w' v2 C
  c. The code generates a compiler error at line 2.2 H# d' _" B  @, J, E7 d, |
  d. The code generates a compiler error at line 5.
6 [- X& L4 l* M4 K' z  22. d
  x6 x9 h/ p& S9 y  23. abd8 C0 r4 X* E+ `6 k$ g1 H
  24. a
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-21 15:44 , Processed in 0.237699 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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