This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Error in Sun Certified Programmer for Java 6 Study Guide Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Error in Sun Certified Programmer for Java 6 Study Guide" Watch "Error in Sun Certified Programmer for Java 6 Study Guide" New topic
Author

Error in Sun Certified Programmer for Java 6 Study Guide

Jim Carney
Greenhorn

Joined: Oct 13, 2008
Posts: 1
page 829, question 11. looks to me like the answer is C, not A. and the explanaition as to why it is not C is confusing me...

anyone else see this?
Vierda Mila
Ranch Hand

Joined: Feb 25, 2008
Posts: 61
Hi Jim,

Kindly to post above question so we can help you in this forum.

regards,
-Vierda Mila-
[ October 13, 2008: Message edited by: Vierda Mila ]

SCJP 5
Graeme Jenkinson
Greenhorn

Joined: Sep 08, 2008
Posts: 27
Question (hopefully copied without any mistakes!)

Given the following directory structure:



And given the contents of GetJar.java and Foo.java:



If the current directory is test, which set(s) of commands will successfully compile the two java files and produce the output 8? (Choose all that apply.)

A. javac myApp/Foo.java
// put into "test" a jar file that contains myApp/Foo.class
javac -classpath MyJar.jar GetJar.java
java GetJar

B. javac myApp/Foo.java
// put into "test" a jar file that contains myApp/Foo.class
javac MyJar.jar GetJar.java
java GetJar

C. javac myApp/Foo.java
// put into "test" a jar file that contains myApp/Foo.class
javac -classpath MyJar.jar GetJar.java
java -classpath MyJar.jar GetJar

D. javac myApp/Foo.java
// put into "test" a jar file that contains myApp/Foo.class
javac MyJar.jar GetJar.java
java -classpath MyJar.jar GetJar

Answer A.

I also have some doubts about this. I don't see howthe invocation of java in A can find the class Foo. Whereas, in C both javac and java can locate the class Foo. I also agree that the "explaination" given is rather inadequate.

thanks,

Graeme
[ October 14, 2008: Message edited by: Graeme Jenkinson ]
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Even C is wrong because it doesn't has the current directory i.e. a "." in the classpath. I have also posted this error, and many others too, but there has been no response from the authors..


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

Ankit Garg wrote:Even C is wrong because it doesn't has the current directory i.e. a "." in the classpath. I have also posted this error, and many others too, but there has been no response from the authors..


This is an old forum topic, but I just came across this problem in the book. Ankit, as you pointed out, the only answer that work is the following. It is not one of the choices:

javac -classpath MyJar.jar GetJar.java
java -classpath .:MyJar.jar GetJar.java


You mentioned "many other errors". Is there anyplace you/someone might have compiled these errors? Since the otherwise excellent K&B book is my current main study material, it would be very helpful to have this compilation to refer to.

Thanks,
Nidhi


"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Bert is compiling an errata so look forward to it...
Chintan B Shah
Ranch Hand

Joined: Sep 23, 2008
Posts: 83
I posted this same question about a week back.

This question assumes that you don't have CLASSPATH variable set in your ENVIRONMENT VARIABLES.

Thanks to Daniel for helping me figure this out.
Question No. 11-Chapter 10-Wrong answer


Regards,
Chintan
SCJA 1.0


SCJA 1.0
Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 178

why at compiling a . is not included

i thinnk it should be

javac -classpath .:MyJar.jar GetJar.java
java -classpath .:MyJar.jar GetJar

doesn`t javac requires a . (current directory)


Mahtab Alam (OCJP )
Blogs : alamsql.blogspot.in , alammahtab.blogspot.in
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in Sun Certified Programmer for Java 6 Study Guide
 
Similar Threads
a question from Dan's topic mock exam
J++ Swing
Automatic Failure.
clear screen