Welcome Guest | Sign in | Register
File - Discussion Page For Q.2726 | Java Programming Questions and Answers | Java Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > File > Questions and Answers

Q: What will be the result of compiling and run the following code:

public class Test {
public static void main(String... args) throws Exception {
File myDir = new File("test");
// myDir.mkdir();
File myFile = new File(
myDir, "test.txt");
A. create directory "test" and a file name as "test.txt" within the the directory. B. java.io.IOException: No such file or directory
C. Compile with error D. None of the above

Answer and Explanation

Answer:java.io.IOException: No such file or directory

// myDir.mkdir(); is commented so no directory, that’s why exception.

Comment on this Question



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.