It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Reg. Threads : Valiveru's exam 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 "Reg. Threads : Valiveru Watch "Reg. Threads : Valiveru New topic

Reg. Threads : Valiveru's exam

Angela Narain
Ranch Hand

Joined: Apr 14, 2001
Posts: 327

Given the code below
public class ThreadDemo extends Thread[
public void run(){
System.out.println("Thread started");
Thread.sleep(20000); //20 seconds sleep
System.out.println("I am Back from my sleep");
catch(InterruptedException e){
System.out.println("I got Interrupted");
Which of the following statements are true? ( ANY ONE )
A.Exactly 20 seconds after the start method
is called "I am Back from my sleep" be printed.
B.We can be sure that atleast after 20 seconds elapsed,
"I am Back from sleep" will be printed.
C.The delay between output "Thread started" and "I am Back
from sleep" is less or more than 20 seconds.
D.None of the above.

I assume it is D
Gagan Indus
Ranch Hand

Joined: Feb 28, 2001
Posts: 346
Agree , it shld be D
A) Exactly ! ? No we cant be sure about sleep time , it is at-least as given in parameter
B) dis option is Poorly-worded , at -least 20 seconds after wht ?
C) Dealy can never be less than as requested
Wht we can be sure about is that The delay between output "Thread started" and "I am Back
from sleep" will be atleast 20 seconds

Gagan (/^_^\)

Gagan (/^_^\) SCJP2 SCWCD IBM486 <br />Die-hard JavaMonk -- little Java a day, keeps you going.<br /><a href="" target="_blank" rel="nofollow">My Blog</a>
I agree. Here's the link:
subject: Reg. Threads : Valiveru's exam
It's not a secret anymore!