Thanks everyone for the tips. And point taken, Bert! So here's the complete question -
Given the following directory structure:
If
test, testdir, subdir and subdir2 are all directories and Finder.class and testfile.txt are files, and given:
And, if the code compiles, the invocation:
java Finder testdir
What is the result?
A. 1
B. 2
C. 3
D. 4
E. 5
F. 100
G. Compilation fails
H. An exception is thrown at runtime
The answer says that C is correct and that File I/O stuff is risky but it's okay for main() to throw an exception.
My question is - how can we say with certainty that an exception won't be thrown at runtime, ruling out H.
Thanks.