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 ans. is E, Please confirm it. Jyotsna
I would say c also, it's the only one that isn't false. It could be none but that would depend on how they meant 'suspended': if they meant with the actual suspend() method then technically, even though it's deprecated, it still works. If by suspend they menat not running then sleep(), wait() or yield() would do it too.
A is wrong because the JVM continues to run until the last thread dies. B is wrong because sleep does not generate an InterruptedException. D is wrong because a thread can also be made by implementing the Runnable interface. E is wrong because sychronize can be used on any method. C is correct because a thread suspension by the JVM is implementation specific and the order that threads run cannot be guaranteed - only indicated by priority. Also the order in which threads run is not possible to determine. The question does not mention the suspend() method at all although the wording is somewhat off-putting. Hope this helps. Cheers Tony