• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Wrapper Q - JDiscuss - Wrong Answer Given

 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • 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
 
Satish Chilukuri
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • 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
 
latha yeduguri
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It won't even compile as it can't recognize the variable i.
 
Nicky Eng
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wont compile due to the reason variable i .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic