Threads on Java related Questions and Answers

Question 1 : Assume the following method is properly synchronized and called from a thread A on an object B:
wait(2000)
After calling this method, when will the thread A become a candidate to get another turn at the CPU?
1. After thread A is notified, or after two seconds
2. After the lock on B is released, or after two seconds.
3. Two seconds after thread A is notified.
4. Two seconds after lock B is released.
View Answer   Discuss with Members

Question 2 : Which of the following will not directly cause a thread to stop?
1. notify()
2. wait()
3. InputStream access
4. sleep()
View Answer   Discuss with Members

Question 3 : Which class or interface defines the wait(), notify(),and notifyAll() methods?
1. Object
2. Thread
3. Runnable
4. Class
View Answer   Discuss with Members

Question 4 : Which method registers a thread in a thread scheduler?
1. run();
2. construct();
3. start();
4. register();
View Answer   Discuss with Members

Question 5 : Which will contain the body of the thread?
1. run();
2. start();
3. stop();
4. main();
View Answer   Discuss with Members

Question 6 : Which method must be defined by a class implementing the java.lang.Runnable interface?
1. void run()
2. public void run()
3. public void start()
4. void run(int priority)
View Answer   Discuss with Members

Question 7 : Which of the following will directly stop the execution of a Thread?
1. wait()
2. notify()
3. notifyall()
4. exits synchronized code
View Answer   Discuss with Members

Question 9 : What is the name of the method used to start a thread execution?
1. init();
2. start();
3. run();
4. resume();
View Answer   Discuss with Members


View 1 - 9 of 9 Questions

* Be the First to Post a Comment.

Submit comment :


Captcha Image
Reload

Ask Question

Captcha Image
Reload

Note : Name and Email never shown.





Subscribe


Become a part of EducationForever. Subscribe to our FREE Newsletter