Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 31

Given the code fragment:

Stream 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?

    Correct Answer: D

    The code contains a typo in the class name used to read file attributes. Instead of 'Basic.File.Attributes.class', it should be 'BasicFileAttributes.class'. This typo will result in a compilation error at line n2 because 'Basic.File.Attributes.class' is not a valid class. Therefore, the correct option is that a compilation error occurs at line n2.

Discussion
rameasyOption: A

Answer is A. It is BasicFileAttributes.class in the question

M_JawadOption: A

Correct answer is A

steefaandOption: A

A is correct. There is typo in Basic.File.Attributes.class as it should be BasicFileAttributes.class.

r1muka5Option: A

Correct answer - A

WilsonKKerllOption: A

Answer is A.