Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 13

Given the code fragment:

public void recDelete (String dirName) throws IOException {

File [ ] listOfFiles = new File (dirName) .listFiles();

if (listOfFiles ! = null && listOfFiles.length >0) {

for (File aFile : listOfFiles) {

if (aFile.isDirectory ()) {

recDelete (aFile.getAbsolutePath ());

} else {

if (aFile.getName ().endsWith (".class"))

aFile.delete ();

}

}

}

}

Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is invoked.

What is the result?

    Correct Answer: A

    The method recDelete() iterates through all files and directories within the specified directory. If it encounters a subdirectory, it makes a recursive call to recDelete() to process that subdirectory. Whenever it finds a file that ends with .class, it deletes that file. Therefore, the method deletes all the .class files in the Projects directory and its subdirectories.

Discussion
AVB22

a tested

r1muka5Option: A

Correct answer A. Tested using IDEA.

asdfjhfgjuaDCVOption: A

A is the correct answer

steefaandOption: A

A is correct.

WilsonKKerllOption: A

Correct answer is A.