• 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

Wrapper Q - JDiscuss - Wrong Answer Given

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

What will happen if it is run with the following command line:
java Parser one

ptions
Select 1 correct option.

1.It will print 'Problem in 0'
2.It will throw an exception and end without printing anything.
3.It will not even compile.
4.It will not print anything if the argument is '1' instead of 'one'.
5.None of the above.


Answer given is: option 5

Correct answer is: option 1

Comment
 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you are in doubt the best thing to do is to compile the code and execute it yourself. The output you get is **THE** correct answer regardless of the what the test answer might say.

Coming to the question, the answer is neither option 1 nor option 5. It is option 3. The variable i is not visible to the catch block.
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks satish
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It won't even compile as it can't recognize the variable i.
 
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wont compile due to the reason variable i .
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic