Java SE 11 Developer (1Z0-819) — Question 143
Which two expressions create a valid Java Path instance? (Choose two.)
Answer options
- A. Paths.get("foo")
- B. Paths.getPath("too")
- C. Path.get(new URI("file:///domains/oracle/test.txt"))
- D. new Path("foo")
- E. Paths.get(URL.create("file:///domains/oracle/test.txt"))
Correct answer: A, E
Explanation
Option A is correct because Paths.get() is a valid method to create a Path instance. Option E is also correct since Paths.get() can handle a URL. Options B, C, and D are incorrect because Paths.getPath() does not exist, Path.get() does not take a URI directly, and new Path() is not a valid constructor in the Java NIO package.