Given that the current directory is empty, and that the user has read and write permissions, and
the following:
import java.io.*;
public class DOS {
public static void main(String[] args) {
File dir = new File("c:\\dir");
dir.mkdir();
File f1 = new File(dir, "f1.txt");
try {
f1.createNewFile();
} catch (IOException e) { ; }
File newDir = new File("newDir");
dir.renameTo(newDir);
}
}
Which statement is true?
A. Compilation fails.
B. The file system has a new empty directory named dir.
C. The file system has a new empty directory named newDir.
D. The file system has a directory named dir, containing a file f1.txt.
E. The file system has a directory named newDir, containing a file f1.txt.
Execution:
On execution of program, this will creates folder in C Drive and also creates an empty text file in that folder.
Result:
E. The file system has a directory named newDir, containing a file f1.txt.
the following:
import java.io.*;
public class DOS {
public static void main(String[] args) {
File dir = new File("c:\\dir");
dir.mkdir();
File f1 = new File(dir, "f1.txt");
try {
f1.createNewFile();
} catch (IOException e) { ; }
File newDir = new File("newDir");
dir.renameTo(newDir);
}
}
Which statement is true?
A. Compilation fails.
B. The file system has a new empty directory named dir.
C. The file system has a new empty directory named newDir.
D. The file system has a directory named dir, containing a file f1.txt.
E. The file system has a directory named newDir, containing a file f1.txt.
Execution:
On execution of program, this will creates folder in C Drive and also creates an empty text file in that folder.
Result:
E. The file system has a directory named newDir, containing a file f1.txt.
No comments:
Post a Comment