• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Help me with Question Kathy Sierra Book

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 466
1
IntelliJ IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As per link link provided its an error.
 
Pooja Sallaria
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vinod Tiwari wrote:As per link link provided its an error.




Thanks for the info
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic