Java OCA OCP Practice Question 1908

Question

Fill in the blanks:

Files.walk() performs a ___ traversal, while Files.find() performs a ___ traversal.

  • A. breadth-first, breadth-first
  • B. breadth-first, depth-first
  • C. depth-first, breadth-first
  • D. depth-first, depth-first


D.

Note

A breadth-first traversal is when all elements of the same level, or distance from the starting path, are visited before moving on to the next level.

A depth- first traversal is when each element's entire path, from start to finish, is visited before moving onto another path on the same level.

Both walk() and find() use depth-first traversals, so Option D is the correct answer.




PreviousNext

Related