What is the result(extends Thread)? : Questions « Thread « SCJP

Home
SCJP
1.Java Source And Data Type
2.Operators
3.Modifiers
4.Type Casting
5.Statements
6.Object Oriented
7.Thread
8.Utility Classes
9.File
SCJP » Thread » Questions 
7.11.11.What is the result(extends Thread)?
class MyThread extends Thread {
   MyThread() {
     System.out.print(" MyThread");
   }
   public void run() {
     System.out.print(" bar");
   }
   public void run(String s) {
      System.out.print(" baz");
  }
}
public class TestThreads {
  public static void main (String [] args) {
    Thread t = new MyThread() {
      public void run() { System.out.print(" foo")}
    };
    t.start();
} }
7.11.Questions
7.11.1.The notify() method is defined in class java.lang.Thread(True/False)
7.11.2.Answer: notify
7.11.3.When a thread is waiting as a result of wait(), it releases its lock(True/False)
7.11.4.Answer: wait() and lock
7.11.5.The notify() method causes a thread to immediately release its lock(True/False)
7.11.6.Answer: notify and lock(2)
7.11.7.notifyAll() notifies all waiting threads, regardless of the object they're waiting on(True/False)
7.11.8.Answer: notifyAll and waiting threads
7.11.9.What is the result of this code(wait and time)?
7.11.10.Answer: wait and time
7.11.11.What is the result(extends Thread)?
7.11.12.Answer: extends Thread
7.11.13.What is the output(two threads)?
7.11.14.Answer: two threads
7.11.15.What is the output(joining thread)?
7.11.16.Answer: joining thread
7.11.17.What is the output(synchronized block and thread)?
7.11.18.Answer: synchronized block and thread
7.11.19.The following code will start the garbage collection mechanism(True/False)?
7.11.20.Answer: System.gc() and garbage collection
7.11.21.Calling Runtime.getRuntime().gc() will probably start the garbage collection mechanism, but there is no guarantee(True/False)?
7.11.22.Answer: Runtime.getRuntime().gc() and garbage collection
7.11.23.The garbage collection Thread has a low priority(True/False)?
7.11.24.Answer: garbage collection and thread
7.11.25.Which method must appear in the class to satisfy the Runnable interface requirements.
7.11.26.Answer: Runnable interface
7.11.27.Which statements are correct after executing the following line:
7.11.28.Answer: thread state
7.11.29.What could be put to XXX to prevent Thread collisions?
7.11.30.Answers: synchronized and synchronizable
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.