1Z0-805 · Question #45
Given the code fragment: public class Test { public static void main (String [] args) { Path path1 = Paths.get("D:\\sys\\asm\\.\\data\\..\\..\\mfg\\production.log")…
The correct answer is A. D:\sys\mfg\production.log. The normalize method removes any redundant elements, which includes any "." or "directory/.." ThegetNameCount method returns the number of elements in the path.Here there are 8 elements (in the redundant path).
Question
Given the code fragment:
public class Test { public static void main (String [] args) { Path path1 = Paths.get("D:\sys\asm\.\data\..\..\mfg\production.log"); System.out.println(path1.normalize()); System.out.println(path1.getNameCount()); } } Oracle 1Z0-805 Exam What is the result?
Options
- AD:\sys\mfg\production.log
- BD:\sys\asm\.\data\. . \mfg\production.log
- CD: \sys\asm\.\data\. . \mfg\production.log
- DD: \sys\mfg\production.log
- ED: \ sys\asm\data\mfg\production.log
How the community answered
(40 responses)- A80% (32)
- B3% (1)
- C3% (1)
- D5% (2)
- E10% (4)
Explanation
The normalize method removes any redundant elements, which includes any "." or "directory/.." ThegetNameCount method returns the number of elements in the path.Here there are 8 elements (in the redundant path).
Topics
Community Discussion
No community discussion yet for this question.