Page 1 of 1

About Question enthuware.ocpjp.v7.2.1525 :

Posted: Mon Dec 03, 2018 11:36 am
by mchristiaan
I'm using the book OCP Java SE 7 1ZO-804 from Mala Gupta - who writed the following in the book:

A WatchKey can be in multiple states:
■ Ready—A WatchKey is initially created with a ready state.
■ Signaled—When an event is detected, the WatchKey is signaled and queued. It can be retrieved using WatchService’s methods poll() or take().
■ Cancelled—Calling method cancel() on a WatchKey or closing the WatchService cancels a WatchKey.
■ Valid—A WatchKey in a ready or signaled state is in a valid state.

So she's saying that Valid is a state and you are saying Invalid maybe is a correct state? I'm confused.

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

Posted: Mon Dec 03, 2018 9:51 pm
by admin
Did you read the explanation provided with the question? It explains exactly what you are asking.

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

Posted: Mon Dec 03, 2018 10:21 pm
by mchristiaan
If I didn't read it I wouldn't be asking about which one (Valid or Invalid state) is a correct state :S So to conclude by using your answer (the explanation) the book is stating it wrong?

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

Posted: Tue Dec 04, 2018 12:07 am
by admin
Well, the explanation clearly explains why we consider invalid as a state and also explains the ambiguity and contradiction involved in this matter.

You might want to ask the author of that book about their position. If they don't consider it a state, then only they can explain the reason behind their position.

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

Posted: Tue Dec 04, 2018 12:11 am
by admin
The explanation also refers you to official oracle article, which says,
A watch key has a state. At any given time, its state might be one of the following:

Ready indicates that the key is ready to accept events. When first created, a key is in the ready state.
Signaled indicates that one or more events are queued. Once the key has been signaled, it is no longer in the ready state until the reset method is invoked.
Invalid indicates that the key is no longer active. This state happens when one of the following events occurs:
The process explicitly cancels the key by using the cancel method.
The directory becomes inaccessible.
The watch service is closed.