wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Help me with Question Kathy Sierra Book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Help me with Question Kathy Sierra Book" Watch "Help me with Question Kathy Sierra Book" New topic
Author

Help me with Question Kathy Sierra Book

Pooja Sallaria
Greenhorn

Joined: Feb 12, 2010
Posts: 11
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

Joined: Aug 03, 2008
Posts: 9291
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Pooja Sallaria
Greenhorn

Joined: Feb 12, 2010
Posts: 11
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

Joined: Feb 06, 2008
Posts: 459
    
    1
As per link link provided its an error.


Vinod Tiwari | Twitter
Pooja Sallaria
Greenhorn

Joined: Feb 12, 2010
Posts: 11
Vinod Tiwari wrote:As per link link provided its an error.



Thanks for the info
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help me with Question Kathy Sierra Book
 
Similar Threads
Classpath - Question 2
K&B Master Exam Question 68
K&B SCJP 5 Chapter 10, #10 Exam Error?
Possible question eligible for errata
Class path question