posted 5 years ago
Hi
Assuming the current directory is /animals/cute, which are possible results of executing
the following code? (Choose all that apply.)
A. It compiles but may throw an exception at runtime.
B. The code will not compile because of line u1.
C. The code will not compile because of line u2.
D. The code will not compile because of line u3.
E. It prints all .java files in the /animals directory tree.
F. It prints all .java files in the /animals/cute directory tree.
G. It prints all .java files in the root directory tree.
Correct answer is stated as AG.
Why are answers EFG not correct? Files.walk recursively walks a file tree. There is
-a root directory tree
-a /animals directory tree
-a /animals/cute directory tree
(and actually possibly many other directory trees descending down from /).
For each of these, the *.java files will be printed. So E,F and G are correct.