aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I think the answer should be Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "I think the answer should be "B" ?  K&B SCJP5 errata" Watch "I think the answer should be "B" ?  K&B SCJP5 errata" New topic
Author

I think the answer should be "B" ? K&B SCJP5 errata

Harry Henriques
Ranch Hand

Joined: Jun 17, 2009
Posts: 206
Help me out here. If you are in the xcom directory and the classpath is set to classpath . ,
then when you execute the javac command in the xcom directory, javac should find A.class. Can you tell me what I'm missing?

Thanks,
Harry


5. Given the default classpath:
/foo

And this directory structure:
______ foo
________|
________test
__________|
__________xcom
______________|--A.class
______________|--B.java

And these two files:




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:
® 3 C is correct. In order for B.java to compile, the compiler first needs to be able to find
B.java. Once it's found B.java it needs to find A.class. Because A.class is in the
xcom package the compiler won't find A.class if it's invoked from the xcom directory.
Remember that the -classpath isn't looking for B.java, it's looking for whatever classes
B.java needs (in this case A.class).
®˚ A, B, and D are incorrect based on the above. E is incorrect because the compiler can't
find B.java. (Objective 7.2)
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9304
    
  17

Please try to Search First as someone else might have had the same problem earlier so it might be already solved. If you search using xcom, then you'll find a lot of discussions like the following

http://www.coderanch.com/t/449709/Programmer-Certification-SCJP/certification/classpath-K-B
http://www.coderanch.com/t/431008/Programmer-Certification-SCJP/certification/K-B-chapter-Q-classpath


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 453

there is nothing wrong in the solution. just try to implement the structure in your system & check the options.

avi sinha


SCJP 5.0 SCWCD 5.0
Harry Henriques
Ranch Hand

Joined: Jun 17, 2009
Posts: 206
Thanks for the feedback, Ankit and Avi. I've figured out what I was missing when I looked at the code snippets.



If /foo/test/xcom/ contains A.class and B.java, then the following command line instructions are correct.

>cd /foo/test
>javac -classpath . xcom/B.java



if /foo/test/xcom/ contains A.class and B.java, then the following command line instructions are correct.

>cd /foo/test/xcom
>javac -classpath . B.java

I didnt' take the statements into account.

Thanks,
Harry

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I think the answer should be "B" ? K&B SCJP5 errata