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 Classpath Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Classpath Query" Watch "Classpath Query" New topic
Author

Classpath Query

Ganesh Kumar
Greenhorn

Joined: Dec 18, 2006
Posts: 11
Hi Friends,

This is the question from our certification book. I am not getting the explanation given. Can any one help me out?

Answer: C

I felt the answer to be B. When I execute B option is say that class A not accessible.

---------------------------------------------------------------------------

Given the default classpath:
/foo

And this directory structure:

foo
|
test
|
xcom
|--A.class
|--B.java


And these two files:

package xcom;
public class A { }

package xcom;
public class B extends A { }

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
Ganesh Kumar
Greenhorn

Joined: Dec 18, 2006
Posts: 11
I found after running few samples...

When I compile B.java by having xcom as a current dir then it is searching for xcom package inside xcom(since A should be within the same package. No Imports!). Since it it could not find the xcom folder it says A.class is not accessible.

Am I correct? I am not sure... This is just my idea... Any thoughts?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Classpath Query