Oracle Certified Professional Java Se 8 Programmer · Free Practice Question Medium

Question 52

Given code of Test.java file: 

System.getProperty("user.home") returns the HOME directory of the User (Both in windows and Linux).

What will be the result of compiling and executing Test class?

  • A It will only print the paths of directories and files under HOME directory.
  • B It will only print the paths of files (not directories) under HOME directory.
  • C It will print the paths of directories, sub-directories and files under HOME directory.
  • D It will print the paths of files (not directories) under HOME directory and its sub-directories.
Reveal correct answer

Correct answer: A

Explanation

Files.list(Path) returns the object of Stream<Path> containing all the paths (files and directories) of current directory. It is not recursive.


For recursive access use overloaded Files.walk() methods.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need