Page 1 of 1

About Question enthuware.ocpjp.v8.2.1673 :

Posted: Sun Nov 29, 2015 4:15 am
by ashish
Given the following code for monitoring a directory:         

Path path = Paths.get(directoryPath);         
WatchService watchService = FileSystems.getDefault().newWatchService();         path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE,                         StandardWatchEventKinds.ENTRY_MODIFY,
                        StandardWatchEventKinds.ENTRY_DELETE);         

while(true){             
WatchKey key = watchService.take(); //waits until a key is available          
System.out.println(key.isValid());                         

 for (WatchEvent<?> watchEvent : key.pollEvents())             {               
 Kind<?> kind = watchEvent.kind();                
System.out.println(kind);             }         }

A file is created and then deleted from the monitored directory.
How many events will be printed by the above code?

There are four option available.
A 1
B 2
C 3
D 4

Query - In questions above there is no system.out.println for printing events.

Answer is A - 1 event .
I would like to know , how 1 is came for said questions.

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

Posted: Sun Nov 29, 2015 9:29 am
by admin
You are right. It should be System.out.println(watchEvent); instead of System.out.println(kind); Fixed.
thank you for your feedback!

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

Posted: Mon Nov 30, 2015 6:28 pm
by ashish
Thanks for fixed.
How i can get update in my system ?

What is the process to get updated questions and answer ?

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

Posted: Mon Nov 30, 2015 8:05 pm
by admin
You may just download the question bank again from our website.
-Paul.