Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam 1z0-809 topic 1 question 191 discussion

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

Given the code fragment:
Stream<Path> files = Files.list(Paths.get(System.getProperty("user.home"))); files.forEach (fName -> { //line n1 try {
Path aPath = fName.toAbsolutePath(); //line n2
System.out.println(fName + ":"
+ Files.readAttributes(aPath, Basic.File.Attributes.class).creationTime
());
} catch (IOException ex) {
ex.printStackTrace();
});
What is the result?

  • A. All files and directories under the home directory are listed along with their attributes.
  • B. A compilation error occurs at line n1.
  • C. The files and folders in the home directory are listed along with their attributes.
  • D. A compilation error occurs at line n2.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
steefaand
2 months, 2 weeks ago
Selected Answer: C
C is correct assuming typos.
upvoted 1 times
...
petetsai
2 years, 3 months ago
Basic package dosen't exsist... readAttributes will fail to compile.
upvoted 1 times
WilsonKKerll
2 years, 1 month ago
import java.nio.file.attribute.BasicFileAttributes;
upvoted 1 times
...
...
Huim
2 years, 11 months ago
What's the difference between A and C?
upvoted 1 times
Svetleto13
2 years, 10 months ago
They are 2 similar questions use walk() and list() methods.We use list() in this one and thats why answer is C.The main difference between walk() and list is that list(dir) gives a stream of files in the directory dir , while walk() method walk the subtree of its argument including the root of subtree—the directory itself.I hope this is useful.
upvoted 7 times
...
...
jduarte
3 years, 2 months ago
A is correct.
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 ...