File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Development chapter - a few questions. 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 "Development chapter - a few questions." Watch "Development chapter - a few questions." New topic
Author

Development chapter - a few questions.

Jan Osykowski
Ranch Hand

Joined: Jul 15, 2010
Posts: 41
Hey guys,

I got some question about the Development Self Test.

First of all the question number 12.



And as the right answers the F and G are listed:

F. java -classpath .:test/MyJar.jar GoDeep
G. java -classpath test/MyJar.jar:. GoDeep


but I also think that the answer C is good:

C. F. java -classpath test/MyJar.jar GoDeep

(which is the same as F and G just without the current directory to look for)

but if we are in the directory "x" then there is nothing to look for there. I mean, the GoDeep.class while executed will look for Foo.class which is accesible in test/MyJar.jar so the classpath equal to "test/MyJar.jar" should be enought, no? What do you guys think?

And another question number 11 which is cited here: http://www.coderanch.com/t/474863/java-programmer-SCJP/certification/Mistake-GuideBook-SCJP-Java-Chapter

I am wondering how would the correct answer look like. Why it is not C? I mean the JAR file is in the current directory so just pointing it shouldn't be bad. Or another solution I can see is something like this:



What would be the correct solution for this task? I mean besides the 4 proposed in the answer sheet.

Cheers,
Jan.
Sahil Kapoor
Ranch Hand

Joined: Sep 12, 2009
Posts: 316
javac sees the current directory by default for .java files

java looks for .class files only in the default classpath ot the classpath you mentioned......
If you do not mention . (current Directory) then it woild not be able to find GODeep.class. Hence it is mandatory .


SCJP 6.0 96%

(Connecting the Dots ....)
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

Sahil Kapoor wrote:javac sees the current directory by default for .java files
java looks for .class files only in the default classpath ot the classpath you mentioned......


in case of relative class paths JVM looks for current directory................
but for absolute classpath........current directory doesnot matter.........because we have to give the complete path of file


SCJP6.0,My blog Ranchers from Delhi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Development chapter - a few questions.
 
Similar Threads
Sun certified programmer book - chapter 10 question 12 - clarification
Doubt: Qn 12 from K&B SCJP 6.0 chapter Development
Doubt about Question 12 in Chapter 10 Quiz (K&B)
Questions about classpath on SCJP book.
java command: classpath or not classpath?