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 Valid Statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Valid Statement" Watch "Valid Statement" New topic
Author

Valid Statement

Alk
Greenhorn

Joined: Feb 02, 2000
Posts: 25
Which of the following statements is valid?
A.The JVM runs till the main method exits, even if there are other user threads running.
B.An InterruptedException occurs when the sleep() method is called on a thread.
C.A thread can be suspended for an indefinite duration of time.
D.A thread can be made in Java only by subclassing the Thread class.
E.The synchronize keyword can be used only in a method that is part of a class that is derived from Thread.
I think the correct answers are B) and c)
Any Suggestions?
Alk
Sridhar Garimella
Ranch Hand

Joined: Feb 18, 2000
Posts: 73
Which of the following statements is valid?
A.The JVM runs till the main method exits, even if there are other user threads running.
B.An InterruptedException occurs when the sleep() method is called on a thread.
C.A thread can be suspended for an indefinite duration of time.
D.A thread can be made in Java only by subclassing the Thread class.
E.The synchronize keyword can be used only in a method that is part of a class that is derived from Thread.
I think the correct answers are B) and c)
Any Suggestions?
Alk

I think u are right.D and E are wrong because thread can be created either extends Thread or implements Runnable.A is also wrong because jvm runs even if the main thread terminates and other threads still there.This case occurs if main thread has low priority and other user threads have high priority.

Thanks,<br />Sridhar.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I think, InterruptedException will not occur when sleep() is called on a thread, but the thread will be moved from running state to sleeping state. While sleeping, it can get that exception.
Lucy C
Ranch Hand

Joined: Feb 09, 2000
Posts: 53
Yes, B is definitely wrong - an InterruptedException is thrown when interrupt() is called on a thread. A sleeping thread can throw this exception if it is interrupted by another thread - hence the fact that sleep() throws InterruptedException.
josephine chen
Ranch Hand

Joined: Oct 29, 2002
Posts: 216

A.The JVM runs till the main method exits, even if there are other user threads running.//f
The Java Virtual Machine continues to execute threads until --All threads that are not daemon threads(means user threads) have died, either by returning from the call to the run method or by throwing an exception that propagates beyond the run method.
B.An InterruptedException occurs when the sleep() method is called on a thread.
Throws:InterruptedException - if another thread has interrupted the current thread.

C.A thread can be suspended for an indefinite duration of time.
//f
D.A thread can be made in Java only by subclassing the Thread class. //f
E.The synchronize keyword can be used only in a method that is part of a class that is derived from Thread. //f
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Valid Statement
 
Similar Threads
barry boone newtest q. 26
Thread
choose one correct ans. -thread
private static
Problem : Threads ; Reference Cert Pal 2