aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes JQuest Mock Exam Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "JQuest Mock Exam Question" Watch "JQuest Mock Exam Question" New topic
Author

JQuest Mock Exam Question

Bin Zhao
Ranch Hand

Joined: Oct 04, 2000
Posts: 73
I have a question about the fol from JQuest Mock Exam
Read the following snippet carefully
1. public synchronized void someMethod() {
2. //lots of code
3. try {
4. Thread.sleep(500);
5. } catch(InterruptedException e) {
6. //do some things here.
7. }
8. //more and more code here
9. }
Select all correct answers
a) //ignored
b)The Thread sleeps at least 500ms if not interrupted.
c) when thread go to sleep,it release the lock on the object.
d)The "sleeping" threads always have the lock on the object.
question:
why the answer are c) and d)
I chose b) and c)
I think c) conflicts with d)
Can anyone explain this?
Thx in advance.

Matt DeLacey
Ranch Hand

Joined: Oct 12, 2000
Posts: 318
I agree with you. I strongly believe d is incorrect. Did you copy and paste the answers?
Matt
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3336
    
    8
Calling sleep() does not release the lock. So the ans should be b and d.
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

[This message has been edited by Paul Anil (edited November 11, 2000).]


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
Bin Zhao
Ranch Hand

Joined: Oct 04, 2000
Posts: 73
yes, answer c) and d) are absolutely identical to the meaning of the original test.
Can anyone throw more light on the effect of executing Thread.sleep() in a synchronized method on the lock of that thread holds?
Nijeesh Balan
Ranch Hand

Joined: Oct 09, 2000
Posts: 116
Hi Bin,
Even I feel that b and d are right answers...
B'cos I have read somewhere that sleep() doesn't release the lock on an object..
Thanks,
Nijeesh.


Thanks & Regards,<br />Nijeesh.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JQuest Mock Exam Question