wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Another Error in Master Exam... 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 "Another Error in Master Exam..." Watch "Another Error in Master Exam..." New topic
Author

Another Error in Master Exam...

Marcus Moreno
Ranch Hand

Joined: Aug 17, 2008
Posts: 58
Question from Master Exam from the K&B SCJP book / from the cd from the book..

Question
Given that the MusicPlayer project is on a UNIX system and consists of the following files:
/mp/player/MusicPlayer.java
/mp/classes/player/MusicPlayer.class
/mp/jars/mp.jar
Inside mp.jar file the structure is:
player/MusicPlayer.java
player/MusicPlayer.class
/mp
and the CLASSPATH is set to
/mp/jars
What command(s) can you use to invoke the class player.MusicPlayer? (Choose all that
apply.)
Correct Answer
E: java -cp classes player.MusicPlayer
H: java -cp /mp/jars/cp.jar player.MusicPlayer

H is wrong, because it says "cp.jar" - there is no "cp.jar but only a "mp.jar"!

Cheers,

Marcus
Abel R Gonzalez
Greenhorn

Joined: Feb 18, 2009
Posts: 2
This question also raised my attention because of the -cp argument in option H. I can't try this on UNIX right now, but

java -cp \mp\jars\cp.jar player.MusicPlayer

won't work on Windows. However,

java -cp jars\cp.jar player.MusicPlayer

will, having mp as the current directory like the question specifies.

Is this one of those UNIX/Windows subtleties? I admit I'm not a UNIX hacker
Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032
Abel Gonzalez wrote:This question also raised my attention because of the -cp argument in option H. I can't try this on UNIX right now, but

java -cp \mp\jars\cp.jar player.MusicPlayer

won't work on Windows.
However,

java -cp jars\cp.jar player.MusicPlayer

will, having mp as the current directory like the question specifies.

Is this one of those UNIX/Windows subtleties? I admit I'm not a UNIX hacker

Hi Abel,

Are you sure that the command doesn't work in Windows? If not, I think the problem is the root directory, which should probably be something like C:\ instead of \. Try and see if that works.

Also, I think the current directory is irrelevant in this case, since you are not adding the current directory explicitly to the classpath, and if you specify a classpath you must include the current directory explicitly in it, or it won't be used.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Ruben is right. The questions in the actual exam will assume Linux as the underlying operating system. So you'll have to think that way. The questions in the Master Exam is way way similar in pattern to the real exam that's why they also use linux style commands...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Abel R Gonzalez
Greenhorn

Joined: Feb 18, 2009
Posts: 2
Thanks a lot Ruben,

I had missed the point that: / = C:\

/ - UNIX root directory
C:\ - Windows most common root directory
Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032
Abel Gonzalez wrote:Thanks a lot Ruben,

I had missed the point that: / = C:\

/ - UNIX root directory
C:\ - Windows most common root directory

No problem, Abel! Yes, the K&B book normally follows UNIX conventions, and like Ankit said, the questions in the exam will also assume Linux.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Another Error in Master Exam...
 
Similar Threads
Question classpath
Mock question on classpath
Possibly misleading Master Exam question
Mock Exam Question Doubt, 36: 74 from K&B CD
Classpaths