ExamQuestions.com

Register
Login
Java SE 8 Programmer II Exam Questions

Oracle

Java SE 8 Programmer II

12 / 130

Question 12:

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? 

Answer options:

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));