Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Classpath Query

 
Ganesh Kumar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic