会计考友 发表于 2012-8-4 12:33:16

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

  Q1.Here is part of the code for a class which implements the Runnable interface.
  1. public class Whiffler extends Object implements Runnable {
  2. Thread myT ;
  3. public void start(){
  4. myT = new Thread( this );
  5. }
  6. public void run(){
  7. while( true ){
  8. doStuff();
  9. }
  10. System.out.println(“Exiting run”);
  11. }
  12. // more class code
  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 ?
  a. The doStuff method will be called repeatedly.
  b. The doStuff method will never be executed.
  c. The doStuff method will execute at least one time.

  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.
  1. public void countDown() {
  2. for( int i = 10 ; i >= 0 ; i-- ){
  3. String tmp = Integer.toString( i );
  4. System.out.println( tmp );
  5. }
  6. System.out.println(“BOOM!”);
  7. }
  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.
  a. none
  b. 1
  c. 10
  d. 11
  Q3.Select all of the following methods that are instance methods of the Thread class, excluding any methods deprecated in Java 1.2.
  a. start()
  b. stop()
  c. run()
  d. suspend()
  e. sleep( long msec )
  f. toString()
  1. bd
  2. c
  3. acf
页: [1]
查看完整版本: 2011年JAVA认证模拟题第二阶段(1)