• 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

Qestion about command line arguments.

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What is the result?
A. baz has the value of ��
B. baz has the value of null
C. baz has the value of �red�
D. baz has the value of �blue�
E. bax has the value of �green�
F. the code does not compile
G. the program throws an exception
I konw the arguments index starts with 0.In this case must report error.I think the correct answers is G that throws an exception.But the right is F because the declaration of variable retrieving the command line args also shoud begin with 0,i.e.String foo=args[0],otherwise compliation to fail.
who can give me a exact answers?
Thank u for ur helps.
[ February 19, 2003: Message edited by: frank yang ]
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something's wrong with the code. You are defining foo three times.
 
frank yang
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry.I have corrected.
Thanks
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 7 other typos in this code. The code below is a correct and compilable version of the given code.

This code compiles fine since the compiler does not interpret the code it parses. Bounds checking will only be done at runtime by the interpreter. The correct answer is G since the array args has only 3 elements and there is no element at index 3 (that is, there is no fourth element) in the args array.
[ February 19, 2003: Message edited by: Valentin Crettaz ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic