aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes The conflicting answers for these 2 questions! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "The conflicting answers for these 2 questions!" Watch "The conflicting answers for these 2 questions!" New topic
Author

The conflicting answers for these 2 questions!

Richard Yi
Greenhorn

Joined: Feb 04, 2004
Posts: 16
Below are the 2 questions regarding thread, and in parentheses are the standard answers provide to me:
55. Which two CANNOT directly cause a thread to stop executing? (Choose Two) (A,E)
A. Calling the yield method
B. Calling the wait method on an object
C. Calling the notify method on an object
D. Calling the NotifyAll method on an object
E. Calling the start method on another Thread object
60. Which two CANNOT directly cause a thread to stop executing? (Choose Two) (A,C)
A.Existing from a synchronized block
B.Calling the wait method on an object
C.Calling notify method on an object
D.Calling read method on an InputStream object
E.Calling the SetPriority method on a Thread object
You should note that the question is the same but the items for choosing are different. Also you should note that the "notify" was chosen as answer in the latter but not in the former! This is so strange and conflict and I cannot understand!
According my knowledge, I think yield(), wait() and read()(I/O block) could cause a thread to stop directly, but notify() and notifyAll() should wake a thread up and start() is the method let the method run! But the above answers frustrate me! Maybe I'm confusing regarding this conception, would you pls help me and give me the detailed and clear explanation for each item enumerated above? Are there some errors in standard answers?
Thank you very much!
Sudhakar Krishnamurthy
Ranch Hand

Joined: Jun 02, 2003
Posts: 76
Richard,
According to me all the answers provided are wrong, Here's my explanation
First, my understanding of STOP a thread is not runnable but still alive
Q55. yield - MAY cause the thread to stop if we have more threads of the same priority
wait - will cause the thread to stop/move out of runnable state
notify - will NOT cause a thread to stop (correct ans)
notifyall - will NOT cause the thread to stop(correct ans)
start - the thread is in the runnable state (but MAY BE not running)
Hence according to me the correct answers are C,D
Q60. Exit synchornized - Cannot cause a thread to stop(correct ans)
wait - will cause the thread to stop/move out of runnable state
notify - will NOT cause a thread to stop (correct ans)
read method - may or may not cause the thread to stop
setpriority - if the priority is lowered and higher priority thread is in runnable state then the current thread may be pre-empted.
So the correct answers are A,C
Hope this helps
-S
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
I think those questions get all tangled up with the exact meaning of "directly cause" and are therefore worthless.
Bill
Richard Yi
Greenhorn

Joined: Feb 04, 2004
Posts: 16
Many appreciate Sudhakar! Your explanation is so clear that I catch it completely.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: The conflicting answers for these 2 questions!