• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in Sun Certified Programmer for Java 6 Study Guide

 
Jim Carney
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Graeme Jenkinson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Nidhi Sar
Ranch Hand
Posts: 252
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bert is compiling an errata so look forward to it...
 
Chintan B Shah
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic