1Z0-829 Java I/O API and Securing Applications Practice Question
A developer wants to traverse a directory tree to find all files that are symbolic links. Which NIO.2 method should be used to follow symbolic links during traversal?
⚠ Common exam trap
Many exam-takers assume `Files.walk(Path)` without options follows symbolic links by default, but the default behavior is to NOT follow links, and the `FOLLOW_LINKS` option must be explicitly provided to enable that behavior.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Files.walk(Path, FileVisitOption.FOLLOW_LINKS)
`Files.walk(Path, FileVisitOption.FOLLOW_LINKS)` is the only method among the options that both traverses a directory tree recursively and explicitly follows symbolic links. The `FileVisitOption.FOLLOW_LINKS` enum constant instructs the walk to follow symbolic links, allowing the traversal to detect files that are themselves symbolic links. Without this option, `Files.walk` treats symbolic links as regular files and does not follow them, which would miss the target of the link.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Files.newDirectoryStream(Path)
Why it's wrong here
newDirectoryStream does not traverse subdirectories.
- ✗
Files.list(Path)
Why it's wrong here
Files.list only returns entries in the direct directory, not recursive.
- ✗
Files.walk(Path) without options
Why it's wrong here
Without FOLLOW_LINKS, symbolic links are not followed.
- ✓
Files.walk(Path, FileVisitOption.FOLLOW_LINKS)
Why this is correct
This method with FOLLOW_LINKS will follow symbolic links during directory traversal.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-829 question from scratch — 513 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.