Threads Questions and Answers
Practice ModeShowing 10 of 15 questions
Q1
What is the name of the method used to start a thread execution?
Answer: Option B
Q2
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)
Answer: Option C
Q3
Which three are methods of the Object class?
notify();
notifyAll();
isInterrupted();
synchronized();
interrupt();
wait(long msecs);
sleep(long msecs);
yield();
Answer: Option C
Q4
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 ?
Answer: Option C
Q5
Which cannot directly cause a thread to stop executing?
Answer: Option C
Q6
Which two of the following methods are defined
in class Thread?
start()
wait()
notify()
run()
terminate()
Answer: Option A
Q7
Which three guarantee that a thread will leave the running state?
yield()
wait()
notify()
notifyAll()
sleep(1000)
aLiveThread.join()
Thread.killThread()
Answer: Option B
Q8
Which of the following will directly stop the execution of a Thread?
Answer: Option A
Q9
Which method must be defined by a class implementing the java.lang.Runnable interface?
Answer: Option B
Q10
Which will contain the body of the thread?
Answer: Option A