The answer from the Review questions in OCP Oracle Certified Professional
Java SE 8 Programmer II - Chapter 9( page 499) Question.7 is wrong:
In general both x1 and x2 lines are not compiling as there is checked IOException which should be caught or declared - which means that both D and E should be correct answers.
they say that the correct one is F....
7. If the current working directory is /zoo, and the path /zoo/turkey does not exist, then
what is the result of executing the following code? (Choose all that apply.)
Path path = Paths.get("turkey");
if(Files.isSameFile(path,Paths.get("/zoo/turkey"))) // x1
Files.createDirectory(path.resolve("info")); // x2
A. The code compiles and runs without issue, but it does not create any directories.
B. The directory /zoo/turkey is created.
C. The directory /zoo/turkey/info is created.
D. The code will not compile because of line x1.
E. The code will not compile because of line x2.
F. It compiles but throws an exception at runtime.
This should be corrected as either the exception is caught/declare or change the answers to D and E.