I'm getting another doubt.this is frm k&B book
chapter 10 question 3
Given the default classpath:
/foo
And this directory structure:
foo
|
test
|
xcom
|--A.class
|--B.java
And these two files:
package xcom;
public class A { }
package xcom;
public class B extends A { }
Which allows B.java to compile? (Choose all that apply.)
A. Set the current directory to xcom then invoke
javac B.java
B. Set the current directory to xcom then invoke
javac -classpath . B.java
C. Set the current directory to test then invoke
javac -classpath . xcom/B.java
D. Set the current directory to test then invoke
javac -classpath xcom B.java
E. Set the current directory to test then invoke
javac -classpath xcom:. B.java
Answer:C
Explanation in book:
classpath isn't looking for B.java its looking for whatever classes B.java needs
I don't understand why A> and B> are wrong..
In xcom directory if we are giving command "javac B.java" then it should compile since B.java and A.class both are present in that directory.But it doesn't happen so.
If B.java doesn't need other class files then A> and B> works f9 but if it needs class files as of here it needs A.class so it doesn't work...
I can't understand properly.
please explain in detail...
thanks
with regards
sawan