This is Question number 10 from chapter 10 of Kathy Sierra Book.
If three versions of MyClass.java exist on a file system:
Version 1 is in /foo/bar
Version 2 is in /foo/bar/baz
Version 3 is in /foo/bar/baz/bing
And the system's classpath includes:
/foo/bar/baz
And this command line is invoked from /foo
javac -classpath /foo/bar/baz/bing:/foo/bar MyClass.java
Which version will be used by javac?
A. /foo/MyClass.java
B. /foo/bar/MyClass.java
C. /foo/bar/baz/MyClass.java
D. /foo/bar/baz/bing/MyClass.java
E. The result is not predictable.
In Book, Answer given is C. But in my opinion answer should be "error :cannot read file MyClass".
Reason being here we are in folder foo , classpath helps to locate the imports used in file and not the file itself.
Unless we do it like this :- javac bar/baz/bing/MyClass.java ,
Java compiler wont be able to locate this.
I also tried this example on my system, with result as can not find.
Please help me if my understanding is incorrect.