Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?

Given the code fragment:
Path file = Paths.get (“courses.txt”);
// line n1
Assume the courses.txt is accessible.
Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?
A. List<String> fc = Files.list(file);
fc.stream().forEach (s – > System.out.println(s));
B. Stream<String> fc = Files.readAllLines (file);
fc.forEach (s – > System.out.println(s));
C. List<String> fc = readAllLines(file);
fc.stream().forEach (s – > System.out.println(s));
D. Stream<String> fc = Files.lines (file);
fc.forEach (s – > System.out.println(s));

Download Printable PDF. VALID exam to help you PASS.

2 thoughts on “Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.