a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 120|回复: 1

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q55.What is wrong with the following code?& t0 O/ f4 L# l5 C
  1. final class First {! w  p% ?, |- u$ l: T$ G* Q
  2. private int a = 1;
2 ~' s% j/ }3 u  3. int b = 2;5 U1 F( N' d, Q/ N
  4. }& \) K  ?0 c4 C$ s+ Q& f) S
  5. class Second extends First {
$ @/ y2 P& O0 h( O$ G1 a  6. public void method() {) J- O) k( n" D% e2 H& E2 b
  7. System.out.println(a+b);$ P& X0 p, v# k. {
  8. }
  D6 e  p6 X  u( m. f- x, [  9. }# J! p, Q  l; y6 b) U
  a. You cannot invoke println() without passing it a string.6 m3 v" P- E7 Y7 J# c/ X8 [3 x6 i
  b. Because a is private, no classes other than First can access it.
- I' g2 s+ y" \  c. Second cannot extend First.
$ T- f/ c9 U. ^. Y4 w, B0 c% ]  d. final is not a valid keyword for a class.
' a. r& O9 \: d. L  Q56.What is displayed when the following piece of code is executed.* ], U4 I. V3 k+ B
  1. class Test extends Thread {$ w5 Z/ O9 x4 C& Z' |8 Q5 }3 Z- v
  2. public void run() {7 x3 s  }* N9 N3 \' o
  3. System.out.print(“1 “);
# z( C4 O9 E: `1 z1 l6 q% x' ^# B  4. yield();$ _  w+ C# p% A* k
  5. System.out.print(“2 “);
. n7 T/ p2 C, Z6 {) ~0 Y3 \/ c  6. suspend();% }; e) P' r; b9 r. M3 o
  7. System.out.print(“3 “);7 q( ]1 |5 s2 |/ n4 @+ J) ]; v

) p1 q% E2 S3 y; o1 {- M/ M( T$ K  8. resume();
回复

使用道具 举报

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

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

</p>  9. System.out.print(“4 “);
+ ?8 B- d6 j2 p, n! n. E  10. }
; `9 f1 N2 [4 K% C* X  11 public static void main(String []args) {" Q$ t0 E! s# G
  12. Test t = new Test();
  u. ~# y) j2 j# O% K( Q  13. t.start();1 ~5 d2 L2 e+ V: }
  14. }" ~" y3 H/ X8 O3 q: O: |
  15. }8 @1 H1 U# c- z" a" n, g
  a. Nothing, this is not a valid way to create and start a thread.6 D2 V# o, ^# v, p
  b. 1 2
& o7 C6 u( i* b% @5 y0 B( S  c. 1 2 3
  M  ~8 L( W: k" j& m8 q0 ]  d. 13 v# B/ S8 E( W2 L! ^8 P& ~
  Q57.What must be true for the RunHandler class so that the instances of RunHandler can be used as written in the following code?5 C$ E& s3 b7 x- y4 W+ N
  1. class Test {
1 G9 G" c; g1 ]! o6 {3 Z: [  2. public static void main(String args[]){. _: G7 h# A9 P" F. O" m: O
  3. Thread t = new Thread(new RunHandler());  X  @) F, A& b
  4. t.start();. t; h* d6 L+ M8 v3 i0 B4 U8 o. R
  5. }
! K$ \! s, _# c' s% Y+ S  6. }" L* ]; ?4 O* l! F& p7 \1 }
  Select all valid answers ?( Y4 o1 H* C3 O# L
  a. RunHandler must only implement the java.lang.Runnable interface.; i2 l% m, [/ M
  b. RunHandler must only extend the Thread class.
% R1 w5 g- F- k, ?+ i  c. RunHandler must extend the Thread class or implement Runnable interface.
, g& S9 A1 |+ h  d. RunHandler must provide a run() method declared as public and returning void.
5 i+ O# G0 m/ c$ Z) j7 [  55. c
$ r0 ]5 U0 k2 [- y3 K  56. b# d/ v2 G5 s3 y2 X, L4 u
  57. cd
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-22 02:57 , Processed in 0.189299 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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