Java SE 8 Programmer II — Question 203

Given the code fragment:
Stream<Path> files = Files.walk(Paths.get(System.getProperty("user.home"))); files.forEach (fName -> { //line n1 try {
Path aPath = fName.toAbsolutePath(); //line n2
System.out.println(fName + ":"
+ Files.readAttributes(aPath, Basic.File.Attributes.class).creationTime
());
} catch (IOException ex) {
ex.printStackTrace();
});
What is the result?

Answer options

Correct answer: A

Explanation

The correct answer is A because the code successfully lists all files and directories within the user's home directory along with their attributes. Option B is incorrect as there is no compilation error at line n1, and options C and D do not fully capture the scope of the output.