• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is this question wrong right?This question is from scjp preparation book.

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,everyone,Is this question wrong right?I think,none of the answers is correct,right?
Given the following directory structure:


And given the contents of GetJar.java and Foo.java:


If the current directory is "test", and myApp/Foo.class is placed in a JAR file called MyJar.jar
located in test, which set(s) of commands will compile GetJar.java and produce the output 8?
(Choose all that apply.)
A. javac -classpath MyJar.jar GetJar.java
java GetJar
B. javac MyJar.jar GetJar.java
java GetJar
C. javac -classpath MyJar.jar GetJar.java
java -classpath MyJar.jar GetJar
D. javac MyJar.jar GetJar.java
java -classpath MyJar.jar GetJar
Answer:
􀀂 ✓ A is correct. Given the current directory and where the necessary files are located, these
are the correct command line statements.
􀀂􀀁 B and D are wrong because javac MyJar.jar GetJar.java is incorrect syntax. C is wrong
because the -classpath MyJar.java in the java invocation does not include the test directory.
(Objective 7.5)

Including the classpath for GetJar and the necessary class path(Foo class) when executing GetJar will be correct I think.That is :

Am I right?
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
 
Ian Su
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Deepak Bala wrote:Does this help -> https://coderanch.com/t/270643/java-programmer-SCJP/certification/Error-Sun-Certified-Programmer-Java



Thank you,you consolidate my opinion!Thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic