You can always just try these problems to see how they work. Basically, this one comes down to needing the classpath to be foo/test and being able to find the B.java file we want to compile.
Which allows B.java to compile? (Choose all that apply.)
A. Set the current directory to xcom
then invoke javac B.java
No good. You said the classpath was set to foo, not foo/test
B. Set the current directory to xcom
then invoke javac -classpath . B.java
Also no good. Now the class path is foo/test/xcom.
C. Set the current directory to test
then invoke javac -classpath . xcom/B.java
Good one. The classpath is foo/test and we tell javac where to find the file to compile.
D. Set the current directory to test
then invoke javac -classpath xcom B.java
No good at all. The classpath is wrong and javac can't find the file.
E. Set the current directory to test
then invoke javac -classpath xcom:. B.java
No good. The classpath is OK despite the extra entry, but javac can't find the file.
The correct answer is C. But what would happen if I removed the package declaration from two files above still leaving them in the same directory ?
Would the correct answer be B ?
Yes