What is the result?

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?

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?

A.
The method deletes all the .class files in the Projects directory and its subdirectories.

B.
The method deletes the .class files of the Projects directory only.

C.
The method executes and does not make any changes to the Projects directory.

D.
The method throws an IOException.



Leave a Reply 8

Your email address will not be published. Required fields are marked *


Piotr Droś

Piotr Droś

A is correct

FreeM

FreeM

A is correct

Berti John

Berti John

A. The method deletes all the .class files in the Projects directory and its subdirectories.

Berti John

Berti John

A. is correct