Given the following code:
import java.io.*; public class Main { public static void main(String[] args) throws IOException, ClassNotFoundException { String[] dirNames = {//ww w . ja v a 2 s . c om "." + File.separator + "dir1", "." + File.separator + "dir2", "." + File.separator + "dir1" + File.separator + "dir2" }; for(String dir : dirNames) { File file = new File(dir, "myFile.txt"); System.out.print(/* INSERT EXPRESSION HERE */); // (1) } } }
Assume that each directory named in the array dirNames
has a file named "myFile.txt".
Which expressions, when inserted at (1), will result in the output truetruetrue
?
Select the three correct answers.
found()
isFile()
isDirectory()
exists()
isAFile()
isADirectory()
(b), (c), (d)
The class File does not have methods called found, isAFile()
, or isADirectory()
.