exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 50 discussion

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

The data.doc, data.txt and data.xml files are accessible and contain text.
Given the code fragment:
Stream<Path> paths = Stream.of (Paths. get("data.doc"),
Paths. get("data.txt"),
Paths. get("data.xml"));
paths.filter(s-> s.toString().contains("data")).forEach(
s -> {
try {
Files.readAllLines(s)
.stream()
.forEach(System.out::println); //line n1
} catch (IOException e) {
System.out.println("Exception");
}
}
);
What is the result?

  • A. The program prints the content of data.txt file.
  • B. The program prints: Exception <<The content of the data.txt file>> <<The content of the data.xml file>>
  • C. A compilation error occurs at line n1.
  • D. The program prints the content of the three files.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
sansay61
Highly Voted 4 years, 1 month ago
D is correct.
upvoted 9 times
...
fffff
Highly Voted 3 years, 12 months ago
D is correct, tested
upvoted 5 times
...
6c84cb9
Most Recent 5 months, 4 weeks ago
D is correct.
upvoted 1 times
...
asdfjhfgjuaDCV
11 months ago
Answer is D.Tested
upvoted 1 times
...
steefaand
12 months ago
Selected Answer: D
D is correct.
upvoted 1 times
...
iSnover
1 year ago
Selected Answer: D
The answer is the letter D, all files can be read and printed. Answer B could be correct but the question makes it clear that all files can be read and contain text.
upvoted 1 times
...
Shad657
1 year, 6 months ago
D is correct, tested. The given code reads from all 3 types of files- DOC, TXT, XML
upvoted 1 times
...
tuyetan
1 year, 8 months ago
B. Files.readAllLines() reads text files where each line is represented as a string. ".doc" files are binary files.
upvoted 1 times
shivkumarx
10 months, 2 weeks ago
a .doc file can still contain text
upvoted 1 times
...
...
Kim514
1 year, 10 months ago
D. The program prints the content of the three files.Tested.
upvoted 1 times
...
lchowen
2 years, 4 months ago
Not sure if you guys really test the code...I created 3 files and successfully read the .txt file and .xml file. Only the .doc file fails. Answer is B for sure.
upvoted 2 times
...
WilsonKKerll
2 years, 10 months ago
Answer is D.
upvoted 1 times
...
aymanj
3 years, 10 months ago
Answer is D .. Tested Stream<Path> paths = Stream.of (Paths. get("data.doc"), Paths. get("data.txt"), Paths. get("data.xml")); paths.filter(s-> s.toString().contains("data")).forEach( s -> { try { Files.readAllLines(s) .stream() .forEach(System.out::println); //line n1 } catch (IOException e) { System.out.println("Exception"); } } );
upvoted 4 times
...
varconite
4 years, 1 month ago
Answer is B
upvoted 2 times
mjcotan
3 years, 4 months ago
Will be B if, for example, the first file don't exists, but the question says that there isn't any problem with the access to each file.
upvoted 1 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