File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Is the answer right about this question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Is the answer right about this question?" Watch "Is the answer right about this question?" New topic
Author

Is the answer right about this question?

david hu
Ranch Hand

Joined: Jul 20, 2001
Posts: 143
Answer for the following question is a.b.c.e
But I think e is not right. 'cause one thread can stop buy invoke the sleep method of another object( and this object refered to another thread).
From(http://www.javaranch.com/maha/_Mock_Exams/MindQ_s_Sun_Certified_Java_Programmer_Practice_Test.htm Question41)
---
For what reasons might a thread stop execution?
a) A thread with higher priority began execution.
b) The thread's wait() method was invoked.
c) The thread invoked its yield() method.
d) The thread's pause() method was invoked.
e) The thread's sleep() method was invoked.
Fei Ng
Ranch Hand

Joined: Aug 26, 2000
Posts: 1242
Originally posted by david hu:
Answer for the following question is a.b.c.e
But I think e is not right. 'cause one thread can stop buy invoke the sleep method of another object( and this object refered to another thread).
From(http://www.javaranch.com/maha/_Mock_Exams/MindQ_s_Sun_Certified_Java_Programmer_Practice_Test.htm Question41)
---
For what reasons might a thread stop execution?
a) A thread with higher priority began execution.
b) The thread's wait() method was invoked.
c) The thread invoked its yield() method.
d) The thread's pause() method was invoked.
e) The thread's sleep() method was invoked.

Huh?? "and this object refered to another thread"
"e) The thread's sleep() method was invoked. " says that? I dont think it refers to another thread. For example, mythreadobject pass to another anotherthreadobject so call mythreadobject.sleep() in this method cause the thread to sleep?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
Note that sleep is a static method of the Thread class. It is always the Thread that calls sleep that goes to sleep. How could it be any other way?
Also yield is a static method.
All objects have a wait method by virtue of inheritance from Object, however, a Thread calling its own wait method is useless. When wait is used in a program, it is the wait method of a particular object.
Fei Ng
Ranch Hand

Joined: Aug 26, 2000
Posts: 1242
oops.. forgot about that, static. sorry!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is the answer right about this question?