Mcq On Java Threads

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

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

View Answer

2.Which cannot directly cause a thread to stop executing?

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

View Answer

3. Which of the following will directly stop the execution of a Thread?

A. notify()
B. notifyall()
C. wait()
D. exits synchronized code

View Answer

4.Which function of pre defined class Thread is used to check weather current thread being checked is still running?

A. isAlive()
B. Alive()
C. isRunning()
D. Join()

View Answer

5. Which method must be defined by a class implementing the java.lang.Runnable interface?

A. public void run()
B. void run()
C. void run(int priority)
D. public void start()

View Answer

6. Assume the following method is properly synchronized and called from a thread A on an object B:
After calling this method, when will the thread A become a candidate to get another turn at the CPU?

A. After thread A is notified, or after two seconds.
B. Two seconds after thread A is notified.
C. After the lock on B is released, or after two seconds.
D. Two seconds after lock B is released.

View Answer

7.Which will contain the body of the thread?

A. main();
B. stop();
C. start();
D. run();

View Answer

8. Which class or interface defines the wait(), notify(),and notifyAll() methods?

A. Object
B. Class
C. Runnable
D. Thread

View Answer

9. Which of these method of Thread class is used to find out the priority given to a thread?

A. ThreadPriority()
B. get()
C. getPriority()
D. getThreadPriority()

View Answer

10.Which of these method of Thread class is used to Suspend a thread for a period of time?

A. stop()
B. sleep()
C. terminate()
D. suspend()

View Answer

Also check :


* You must be logged in to add comment.