• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt about Question 12 in Chapter 10 Quiz (K&B)

 
Bhaarat Sharma
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question:
Given following directory structure:
x-|
|- GoDeep.class
|
|- test-|
|- MyJar.jar
|
|- myApp-|
|-Foo.java
|-Foo.class

And given the contents of GoDeep.java and Foo.java:
3. public class GoDeep {
4. public static void main(String[] args) {
5. System.out.println(myApp.Foo.d);
6. }
7. }
3. package myApp;
4. public class Foo { public static int d = 8; }

And MyJar.jar contains the following entry:
myApp/Foo.class
If the current directory is x, which commands will successfully execute GoDeep.class and
produce the output 8? (Choose all that apply.)
A. java GoDeep
B. java -classpath . GoDeep
C. java -classpath test/MyJar.jar GoDeep
D. java GoDeep -classpath test/MyJar.jar
E. java GoDeep -classpath test/MyJar.jar:.
F. java -classpath .:test/MyJar.jar GoDeep
G. java -classpath test/MyJar.jar:. GoDeep


Why is option C not valid here??
 
Emanuele Ghe
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bhaarat.

The answer C is not valid because the java command will not find the class GoDeep, because the '.' is not included in the classpath.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic