nerdexam
Oracle

1Z0-829 · Question #21

1Z0-829 Question #21: Real Exam Question with Answer & Explanation

Sign in or unlock 1Z0-829 to reveal the answer and full explanation for question #21. The question stem and answer options stay visible for context.

Using Java I/O API

Question

Assuming that the data, txt file exists and has the following content: Text1 Text2 Text3 Given the code fragment: try { Path p = new File("data.txt").toPath(); String lines = Files.lines(p) .collect(Collectors.joining("-")); System.out.println(lines); String data2 = Files.readAllLines(p).get(3); System.out.println(data2); } catch (IOException ex) { System.out.println(ex); } What is the result?

Options

  • AText1- text2- text3- text1 text2 text3
  • Btext1-text2-text3 A java.lang.IndexOutOfBoundsException is thrown.
  • CText1-text2-text3 text3
  • DText1-Text2-Text3 text3

Unlock 1Z0-829 to see the answer

You've previewed enough free 1Z0-829 questions. Unlock 1Z0-829 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#Files.lines()#Collectors.joining()#Files.readAllLines()#List indexing
Full 1Z0-829 Practice