Assume /data exists as a symbolic link to the directory /source/java within the file system.
Which of the following statements are correct about this code snippet? (Choose all that apply.).
Path path = Paths.get("/data"); if(Files.isDirectory(path) && Files.isSymbolicLink(path)) Files.createDirectory(path.resolve("resource"));
B, C, D.
The first clause of the if/then statement will be true only if the target of the symbolic link, /source/java, exists, since by default isDirectory()
follows symbolic links, so B is correct.
Option A is incorrect because /source/java may not exist or /source/java/resource may already exist.
If /source/java does exist, then the directory will be created at /source/java/resource, and because the symbolic link would be accessible as /data/resource, C and D are both correct.
E is incorrect, because the code compiles without issue.
F is incorrect because the code may throw an exception at runtime, such as when the file system is unavailable or locked for usage; thus it is not guaranteed to throw an exception at runtime.