Exam 1z0-816 All QuestionsBrowse all questions from this exam
Question 23

Given:

String originalPath = “data\\projects\\a-project\\..\\..\\another-project”;

Path path = Paths.get(originalPath);

System.out.print(path.normalize());

What is the result?

    Correct Answer: A

    The normalize() method in the Path class removes redundant elements like '.' (current directory) and '..' (parent directory) from the path. Starting with the original path 'data\projects\a-project\..\..\another-project', the '..' components will move the path up two levels, effectively removing 'projects' and 'a-project'. The normalized path will point to 'data\another-project'.

Discussion
Sa16253748596Option: A

A is true