• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help me with Question Kathy Sierra Book

 
Pooja Sallaria
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ankit Garg
Sheriff
Posts: 9519
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have the SCJP 5 version of the book?? This question is not in my SCJP 6 book. Maybe its an error, checkout the errata...
 
Pooja Sallaria
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit Garg wrote:Do you have the SCJP 5 version of the book?? This question is not in my SCJP 6 book. Maybe its an error, checkout the errata...



It is there in SCJP 5 book.
 
Vinod Tiwari
Ranch Hand
Posts: 466
1
IntelliJ IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per link link provided its an error.
 
Pooja Sallaria
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinod Tiwari wrote:As per link link provided its an error.



Thanks for the info
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic