exam questions

Exam 1z0-809 All Questions

View all questions & answers for the 1z0-809 exam

Exam 1z0-809 topic 1 question 190 discussion

Actual exam question from Oracle's 1z0-809
Question #: 190
Topic #: 1
[All 1z0-809 Questions]

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 = Files.readAllLines(file); fc.stream().forEach (s -> System.out.println(s));
  • D. Stream<String> fc = Files.list (file); fc.forEach (s -> System.out.println(s));
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
asdfjhfgjuaDCV
4 months, 2 weeks ago
C is the correct
upvoted 1 times
...
steefaand
5 months, 3 weeks ago
Selected Answer: C
C is correct.
upvoted 1 times
...
duydn
10 months, 1 week ago
Selected Answer: C
C is correct.
upvoted 1 times
...
NoraYu
2 years, 1 month ago
option D would be right if use method lines(path) rather than list(path)
upvoted 1 times
...
Svetleto13
3 years, 2 months ago
C,tested.
upvoted 4 times
...
maslac
3 years, 3 months ago
Correct answer is C static List<String> readAllLines(Path path) - Read all lines from a file.
upvoted 1 times
...
jduarte
3 years, 6 months ago
Option D, correct answer.
upvoted 1 times
maslac
3 years, 3 months ago
In what parallel universe is this the correct answer? static Stream<Path> list(Path dir) - Return a lazily populated Stream, the elements of which are the entries in the directory.
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago