Hi all,
this question is from Amit poddar's moch test. The answer is" b".
but my question is why not Ans: a, becoz according to RHE(PAge no.
379)
"The File must describe a directory not a file." so this would be a
compile time error as File has argument "12345.msg" that is a file not
a dir.
please explain me.
**************************
Q40) What will be the output if
Consider a directory structure like this (NT or 95)
C:\JAVA\12345.msg --FILE
\dir1\IO.class -- IO.class is under dir1
import java.io.*;
public class IO {
public static void main(String args[]) {
File f = new File("12345.msg");
String arr[] = f.list();
System.out.println(arr.length);
}
}
a) Compiler error as 12345.msg is a file not a directory
b) java.lang.NullPointerException at run time
c) No error , but nothing will be printed on screen
***********************
------------------
Praveen Kumar
Mumbai ,India
email:
bades@vsnl.com