SCJP Threads
By: admin - Tuesday, September 9th, 2008 at 11:01 am
QUESTION : 1
Any class that implements the Runnable interface
has to provide the implementation for the following methods
public void start();
public void run();
1. True.
2. False.
ANS : 2
QUESTION : 2
True or false ?
A thread that has called the wait() method of an object
still owns the lock of the object.
1. True
2. False
ANS : 2
QUESTION : 3
A number of threads of the same priority have relinquished the lock
on a monitor and are in a waiting state after having called the wait()
method of the object. A new thread enters the monitor and calls the
notifyAll() method of the meonitor. Which of these threads will be the
first one to resume?
1. The thread that has been waiting the longest.
2. The thread that was the last one to to exit the monitor.
3. You can never be sure which thread will get to run first.
4. The the first thread that called the wait() method
ANS : 3
QUESTION : 4
Which of these are valid contructors of a Thread object.
1. public Thread(Object obj)
2. public Thread(String name)
2. public Thread(Runnable trgt)
4. public Thread(ThreadGroup grp, Runnable trgt, String name)
5. public Thread(ThreadGroup grp, Object ob)
ANS : 2,3,4
QUESTION : 5
If you call the interrupted() method of a thread object twice
the second call will always return false.
1. True
2. False
ANS : 1
QUESTION : 6
If you call the isInterrupted() method of a thread object twice
the second call will always return false.
1. True
2. False
ANS : 2
QUESTION : 7
Which of the following are methods of the Thread class.
1. public void run()
2. public void start()
3. public void exit()
4. public final void setAccess()
5. public final void setPriority(int priNbr)
6. public final int getPriority()
ANS : 1,2,5,6
QUESTION : 8
Consider the following class
public class Test implements Runnable{
public void run(){}
}
True or False ?
Creating an instance of this class and calling its run() method
will spawn a new thread.
1. True
2. False
ANS : 2
QUESTION : 9
True or false?
A Thread object has a method called notify().
1. False
2. True
ANS : 2
The Thread class has a method notify() inherited from Object.
QUESTION : 10
Calling the destroy() method of a thread object relases all the locks held by
the thread ?
1. True
2. False
ANS : 2