• 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

Command line argument question

 
Greenhorn
Posts: 9
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I found the following question in Oracle's site sample questions section. Posting the url in a code tag as it has the word " p l s" in it.




The answer that they gave sounds wrong. Am I wrong in thinking A to be the answer for the following question?


OBJECTIVE: 7.2: Given an example of a class and a command-line, determine the expected runtime behavior.
10) Given:

Which command-line invocation will produce the output found?
a) java -Dx=y x y z
b) java -Px=y x y z
c) java -Dx=y x x y z (*)
d) java -Px=y x x y z
e) java x x y z -Dx=y
f) java x x y z -Px=y

REFERENCE:
API for java command
Option C is correct. -D sets a property and args[1] is the second argument (whose value is y)



Thanks in advance
 
Ranch Hand
Posts: 276
Netbeans IDE Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its correct - 'C' is the answer
I too thought for a moment that 'A' might be the answer, but then realized that 'x' is the name of the class.
In A : java -Dx=y x y z , the command line arguments are y and z(not x) - that makes this option wrong
 
Guru Vasu
Greenhorn
Posts: 9
Mac Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
....

nice. world is normal again. Thank you Vinoth
 
Vinoth Kumar Kannan
Ranch Hand
Posts: 276
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic