Given:
It is required that if p instanceof Pair then p.isValid() returns true.
Which is the smallest set of visibility changes to insure this requirement is met?
Given the code fragment:
Path currentFile = Paths.get("/scratch/exam/temp.txt");
Path outputFile = Paths get("/scratch/exam/new.txt");
Path directory = Paths.get("/scratch/");
Files.copy(currentFile, outputFile);
Files.copy(outputFile, directory);
Files.delete (outputFile);
The /scratch/exam/temp.txt file exists. The /scratch/exam/new.txt and /scratch/new.txt files do not exist.
What is the result?

Why would you choose to use a peek operation instead of a forEach operation on a Stream?