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

The data.doc, data.txt and data.xml files are accessible and contain text.

Given the code fragment:

Stream paths = Stream.of (Paths. get("data.doc"),

Paths. get("data.txt"),

Paths. get("data.xml"));

paths.filter(s-> s.toString().endWith("txt")).forEach(

s -> {

try {

Files.readAllLines(s)

.stream()

.forEach(System.out::println); //line n1

} catch (IOException e) {

System.out.println("Exception");

}

}

);

What is the result?

data.txt file.

    Correct Answer: A

    The code filters the paths to include only those that end with 'txt'. Therefore, the only file read and printed is data.txt.

Discussion
InnovationOption: A

A. The program prints the content of data.txt file

M_JawadOption: A

the Answer is A

adnano1234Option: A

The correct answer is A

asdfjhfgjuaDCVOption: A

A is the correct answer.Tested

iSnoverOption: A

The answer is A, because on line 4 there is the "endWith("txt")" method that separates the data.txt file which is the only one to be read.

steefaandOption: A

A is correct.