Java OCA OCP Practice Question 310

Question

Which of the following creates a Path object pointing to c:/temp/exam?

Choose all that apply.

  • A. new Path("c:/temp/exam")
  • B. new Path("c:/temp", "exam")
  • C. Files.get("c:/temp/exam")
  • D. Files.get("c:/temp", "exam")
  • E. Paths.get("c:/temp/exam")
  • F. Paths.get("c:/temp", "exam")


E and F are correct

Note

Paths must be created using the Paths.get() method.

This method takes a varargs String parameter, so you can pass as many path segments to it as you like.

A and B are incorrect because you cannot construct a Path directly.

C and D are incorrect because the Files class works with Path objects but does not create them from Strings.




PreviousNext

Related