About Question enthuware.ocpjp.v7.2.1568 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Nisim123
Posts: 42
Joined: Mon Jan 20, 2014 2:26 pm
Contact:

About Question enthuware.ocpjp.v7.2.1568 :

Post by Nisim123 »

I should beg your pardon if this question is out of the scope of the exam of even if it is just a too silly question,
but what is wrong with option 4: IllegalThreadStateException ?
I might guess it is something concerning the Thread class that is not actually the class Object where the wait() method resides..
Looking at the API it says the following:
public class IllegalThreadStateException
extends IllegalArgumentException

Thrown to indicate that a thread is not in an appropriate state for the requested operation. See, for example, the suspend and resume methods in class Thread.
So we might imagine a situation where a call to the wait() method requires this kind of exception....
lets say that a bad coding caused a call to wait() on an object that was already processed by a thread and it is considered dead already and so the call to the wait() method is illegal or something of this kind...
well so many wordings that bring me to the conclusion that there can not be such a scenario since the wait() method is called on an object and not on a thread.
Thanks anyway :roll:

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1568 :

Post by admin »

As you mentioned, the wait method is provided by java.lang.Object (and not Thread). And this method does not throw IllegalThreadStateException. Since the question asks specifically about the exceptions thrown by wait() method, IllegalThreadStateException is incorrect.

As you said, IllegalThreadStateException is thrown by the methods of java.lang.Thread such as start(). You will get this exception if you try to call start on a Thread object that has already been started or is already dead. It has nothing to do with wait though.

HTH,
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests