Page 1 of 1

About Question : enthuware.ocpjp.v8.2.1671

Posted: Tue Mar 28, 2017 1:30 pm
by razorback
Hello, in Test 3 question 5 it asks:
What is the state of the WatchKey at the end of the following code?

Path path = Paths.get("C:/temp");
WatchService watchService = FileSystems.getDefault().newWatchService();
path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE,
StandardWatchEventKinds.ENTRY_MODIFY,
StandardWatchEventKinds.ENTRY_DELETE);
WatchKey key = watchService.take();

In my opinion the state for key is ready, because no event has triggered so far.
I understand the api also like that.
If the first event occurs, then the state would become signaled.

But in the answers it says "signaled" is right.

Can you verify please ?

Best regards

Re: About Question :

Posted: Tue Mar 28, 2017 9:52 pm
by admin
The qid that you have mentioned is for OCAJP 8 question bank but the question belongs to some other question bank. Can you please specify the correct question id or the certification so that I can look it up?

-Paul.

Re: About Question :

Posted: Wed Mar 29, 2017 4:09 am
by razorback
Sorry, my mistake.

enthuware.ocpjp.v8.2.1671
Test 3, question 5

Re: About Question :

Posted: Wed Mar 29, 2017 4:55 am
by admin
The last line is watchService.take(); The call to take will wait until there is an event. Therefore, the status after this line will be Signaled and not Ready.

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

Posted: Wed Mar 29, 2017 5:06 am
by razorback
Well, after this line it will probably be signaled, maybe not, if no event is triggered in the specified folder.
The question says "at the end of the code", NOT after the code with following events in the folder.

So this is IMO a bit mistakeable and i would still say the answer to the question like it is written is ready, not signaled.

API says: "A watch key has a state. When initially created the key is said to be ready. When an event is detected then the key is signalled "

At the end of the code there is no event, so i am pretty sure the state is ready.

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

Posted: Wed Mar 29, 2017 5:27 am
by admin
I have updated the problem statement to make it clear.

thank you for your feedback!

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

Posted: Wed Mar 29, 2017 5:28 am
by razorback
Thank you.