a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 95|回复: 1

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

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
  Q1.Here is part of the code for a class which implements the Runnable interface.
6 m8 U" B8 m# A- u1 [- G+ F# N  1. public class Whiffler extends Object implements Runnable {
! _/ L& }7 m  X; h: R. q9 E  2. Thread myT ;
: c: v5 C! t9 r+ t0 |  3. public void start(){
  X& H5 m3 e/ `$ \  4. myT = new Thread( this );
& d2 x/ D2 j: ?3 c  5. }3 t; q! X# `6 G! `- k8 k- O' g! ]
  6. public void run(){
" F0 z; S0 u1 b+ |( \  7. while( true ){4 R6 M3 J. K/ d' @
  8. doStuff();6 t) z+ x' h& B* g% F
  9. }
& e' a; e/ G( [1 }  10. System.out.println(“Exiting run”);
* ?0 Z+ f2 H) ?1 o( c- |  11. }
7 e3 J- ^0 c. f8 ?! b- \  12. // more class code( P' ~* o# f# D
  Assume that the rest of the class defines doStuff, etc and that the class compiles without error. Also assume that a Java application creates a Whiffler object and calls the Whiffler start method, that no other direct calls to Whiffler methods are made an that the Thread in this object is the only one the application creates. Which of the following are correct statements ?% O1 |, t  x" q- J
  a. The doStuff method will be called repeatedly./ K, S9 U# z% `" u9 h8 S
  b. The doStuff method will never be executed.+ E" q! Y) ?4 |, L
  c. The doStuff method will execute at least one time.
9 h: S/ T  ~) K1 i, S' v9 P9 b1 H$ g8 c0 m- H. x  W! ~
  d. The statement in line 10 will never be reached.
回复

使用道具 举报

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

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

</p>  Q2.Here is a method which creates a number of String objects in the course of printing a count down sequence.7 }" ]8 W: F0 M* P8 @
  1. public void countDown() {& [% i2 o0 k+ a# ^& G7 E
  2. for( int i = 10 ; i >= 0 ; i-- ){4 I# V2 X" j( T2 w
  3. String tmp = Integer.toString( i );
" i2 E* I" ]' ^  4. System.out.println( tmp );
9 F, Q9 t, n( Z" P  5. }
; K; ]' \2 k, s; p% N  6. System.out.println(“BOOM!”);
+ m2 C; S! T. u" E4 E  7. }/ H; S9 _# Z% a  Q/ M9 N
  When the program reaches line 6, how many of the String objects created in line 3 are eligible for garbage collection? Assume that the System.out object is not keeping a reference.. z; M) o2 V: Y( k2 l
  a. none
8 T; F% l2 \9 f  b. 1
7 \& B# c3 w9 ]7 p  c. 104 \" J0 l: Y: ^5 u
  d. 119 {7 s$ j# W+ h; M
  Q3.Select all of the following methods that are instance methods of the Thread class, excluding any methods deprecated in Java 1.2.' K: [% B8 O. n& X& i
  a. start()8 d* P+ k/ b. [5 J9 d
  b. stop()3 K: m( X( c) b  g( H
  c. run()
) E5 W% {( Q7 K# U( _  d. suspend()3 p) \5 [  `' H$ V
  e. sleep( long msec )* \) H  @9 q" @$ h( D, ^9 ~( f
  f. toString()
  f1 ~4 T6 Z% G, J" p  1. bd
% {! N& `4 t$ c$ B  C  2. c) y5 C1 ?# @. m; X
  3. acf
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-21 12:11 , Processed in 0.187102 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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