Java OCA OCP Practice Question 2567

Question

Consider the following code segment:

Path testFilePath = Paths.get("C:\\WINDOWS\\system32\\config\\.\\systemprofile\\Start Menu\\Programs\\Accessories\\Entertainment\\..\\..");
System.out.println("It's normalized absolute path is: " + testFilePath.normalize().toAbsolutePath());

Which one of the following options correctly provides the output of this code segment?

a)C:\\WINDOWS\\system32\\config\\systemprofile\\Start Menu\\Programs\\Accessories\\Entertainment\\

b)C:\WINDOWS\system32\config\systemprofile\Start Menu\Programs\Accessories\Entertainment\

c)C:\WINDOWS\system32\config\systemprofile\Start Menu\Programs 

d) C:\WINDOWS\system32\systemprofile\Start Menu\Programs\Accessories\Entertainment\


c)

Note

The method normalize() removes redundant elements in the path such as . (dot symbol that indicates current directory) and .. (the double dot symbol that indicates the parent directory).

Hence, the resulting path is

C:\WINDOWS\system32\config\systemprofile\Start Menu\Programs.



PreviousNext

Related