• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Very Much Confused !!!

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
5. 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


Correct answer is "C" but how come AFTER SETTING DIRECTORY TO TEST WE CAN SEARCH A.CLASS ??? THE CLASSPATH IS CURRENT DIRECTORY MEANS "TEST DIRECTORY" BUT THE A.CLASS is PRESENT IN XCOM ........

I AM CONFUSED !!!
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi buddy
The class file belongs to package xcom, right? So the directory which is set as CLASSPATH should contain the package(here xcom) as its direct "subdirectory"!! Got it? Its because now the class file's full name is "xcom.A", so xcom should be present in the CLASSPATH directory as a SUBDIRECTORY!

p.s- Same confusion happened to me as well. If you read Kathy Sierra very carefully ,it says exactly this.

"Kathy's the best"
 
Prav sharma
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Buddy !!!
I'll remember this RULE OF THUMB !!!
Hope its valid in every question i encounter !!!

Cheers !!!
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"hello sharma", please check your private messages. You can see them by clicking My Private Messages.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't post duplicates. Your question is also answered where you originally posted.
[ February 15, 2008: Message edited by: marc weber ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic