MCQs
run() method is used to define the code that constitutes the new thread, it contains the code
to be executed. start() method is used to begin execution of the thread that is execution of
run(). run() itself is never used for starting execution of the thread.
None.
None.
(1), (2), and (6) are correct. They are all related to the list of threads waiting on the
specified object.
(3), (5), (7), and (8) are incorrect answers. The methods isInterrupted() and interrupt()
are instance methods of Thread.
The methods sleep() and yield() are static methods of Thread.
D is incorrect because synchronized is a keyword and the synchronized() construct is part of
the Java language.
None.
None.
None.
wait() method is used to tell the calling thread to give up monitor and go to sleep until some
The isAlive( ) method returns true if the thread upon which it is called is still running. It
returns false otherwise.
Polling is a usually implemented by looping in CPU is wastes CPU's time, one thread
being executed depends on other thread output and the other hread depends on the
response on the data given to the first thread. In such situation CPU's time is wasted,
in Java this is avoided by using methods wait(), notify() and notifyAll().