1Z0-805 · Question #7
View the Exhibit: Given the following code fragment: class Finder extends SimpleFileVisitor<Path> { private final PathMatcher matcher; private static int numMatches = 0; Finder() { matcher =…
The correct answer is B. 6. The program will compile and run. Referring to the exhibit there will be six nodes that matches glob:*java.
Question
View the Exhibit:
Given the following code fragment:
class Finder extends SimpleFileVisitor<Path> { private final PathMatcher matcher; private static int numMatches = 0; Finder() { matcher = FileSystems.getDefault().getPathMatcher("glob:*java"); } void find(Path file) { Path Name = file.getFileName(); if (name != null && matcher.matches(name)) { Oracle 1Z0-805 Exam numMatches++; } } void report() { System.out.println("Matched: " + numMatches); } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { find(file); return CONTINUE; } } public class Visitor { public static void main(String[] args) throws IOException { Finder finder = new Finder(); Files.walkFileTree(Paths.get("d:\Project"), finder); finder.report(); } } What is the result?
Exhibits
Options
- ACompilation fails
- B6
- C4
- D1
- E3
How the community answered
(44 responses)- A9% (4)
- B73% (32)
- C2% (1)
- D5% (2)
- E11% (5)
Explanation
The program will compile and run. Referring to the exhibit there will be six nodes that matches glob:*java.
Topics
Community Discussion
No community discussion yet for this question.

