IndiaBIX.com
Search

Java Programming - Threads

@ : Home > Java Programming > Threads > General Questions

Exercise

"Nothing in life is to be feared, it is only to be understood."
- Marie Curie
1. 

What is the name of the method used to start a thread execution?

A. init();B. start();
C. run();D. resume();

2. 

Which two are valid constructors for Thread?

  1. Thread(Runnable r, String name)
  2. Thread()
  3. Thread(int priority)
  4. Thread(Runnable r, ThreadGroup g)
  5. Thread(Runnable r, int priority)

A. 1 and 3B. 2 and 4
C. 1 and 2D. 2 and 5

3. 

Which three are methods of the Object class?

  1. notify();
  2. notifyAll();
  3. isInterrupted();
  4. synchronized();
  5. interrupt();
  6. wait(long msecs);
  7. sleep(long msecs);
  8. yield();

A. 1, 2, 4B. 2, 4, 5
C. 1, 2, 6D. 2, 3, 4

4. 

class X implements Runnable 
{ 
    public static void main(String args[]) 
    {
        /* Missing code? */
    } 
    public void run() {} 
}
Which of the following line of code is suitable to start a thread ?

A. Thread t = new Thread(X);
B. Thread t = new Thread(X); t.start();
C. X run = new X(); Thread t = new Thread(run); t.start();
D. Thread t = new Thread(); x.run();

5. 

Which cannot directly cause a thread to stop executing?

A. Calling the SetPriority() method on a Thread object.
B. Calling the wait() method on an object.
C. Calling notify() method on an object.
D. Calling read() method on an InputStream object.




© 2008-2014 by IndiaBIX™ Technologies. All Rights Reserved | Copyright | Terms of Use & Privacy Policy

Contact us: info@indiabix.com     Follow us on twitter!