1Z0-805 · Question #72
Given the code fragment: public class App { public static void main (String [] args) { path path = paths.get("C\\educations\\institute\\student\\report.txt"); system.out.printIn("getName(0): %s"…
The correct answer is D. getName(0): education. The getName(int index) method returns a name element of this path as a Path object. The subpath(int beginIndex, int endIndex) method returns a relative Path that is a subsequence of the name elements of this path.
Question
Given the code fragment:
public class App { public static void main (String [] args) { path path = paths.get("C\educations\institute\student\report.txt"); system.out.printIn("getName(0): %s", path.getName(0)); system.out.prinIn("subpath(0, 2): %s" path.subpath(0, 2)); } } What is the result?
Options
- AgetName (0): C:\
- BgetName (0): C:\
- CgetName(0): education
- DgetName(0): education
- EgetName(0): report.txt
How the community answered
(25 responses)- A4% (1)
- C8% (2)
- D72% (18)
- E16% (4)
Explanation
The getName(int index) method returns a name element of this path as a Path object. The subpath(int beginIndex, int endIndex) method returns a relative Path that is a subsequence of the name elements of this path.
Topics
Community Discussion
No community discussion yet for this question.