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 Reg. Threads : Valiveru's exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Reg. Threads : Valiveru Watch "Reg. Threads : Valiveru New topic
Author

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");
try{
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="http://www.objectfirst.com/blog" target="_blank" rel="nofollow">My Blog</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reg. Threads : Valiveru's exam
 
Similar Threads
thread
Threads doubt
Some Mock Exam Questions
sleep()
valiveru exam errata - please confirm REAL answers, thanks!