Page 1 of 1

About Question enthuware.ocpjp.v7.2.1671 :

Posted: Sun Feb 28, 2016 11:19 am
by Deleted User 2779
Hi there,

I found this one a little misleading, and answered it wrong. I wondered if actual questions in the exam are like this? At the end of the code, it's not certain if any event has been fired.

I suppose, if there hasn't been an event, then 'key' would be null, and thus would not have any of the states.

So, the only way for 'key' not to be null, and have a state, is if there indeed has been an event. In which case it must be 'signaled'. :)

If 'key' had been assigned from the path.register' statement, then it could be either 'ready' or 'signaled', depending on whether an event had been fired or not. I think that's what confused me.

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

Posted: Sun Feb 28, 2016 7:55 pm
by admin
The call to watchService.take in the last statement WatchKey key = watchService.take(); will not return until there is an event and therefore the state must be signaled at the end of the code.

-Paul.