jQuery in Action, 3rd edition
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

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.
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?
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3634
Calling sleep() does not release the lock. So the ans should be b and d.
Get Certified, Guaranteed!
(Now Revised for the new Pattern)

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

Enthuware - Best Mock Exams and Questions for Oracle 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 & Regards,<br />Nijeesh.
Consider Paul's rocket mass heater.
subject: JQuest Mock Exam Question
It's not a secret anymore!