• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Whizlabs question... their explanations seems weird to me

 
Aj Deschanel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
QUESTION

Options:
a) Compiler error
b) Runtime exception
c) Prints "Match not found"
d) Prints "Match found"

My comment:
I answered "Match not found", which is correct, but their explanation seems a little bit strange to me.

WHIZLABS EXPLANATION
The find method scans the input sequence looking for the next sequence that matches the pattern. Since the starting letter of "Water" is in uppercase, it does not match with "water". So the find method returns false and "Match not found" is printed out. So choice C is incorrect.


My comment:
Even if we change the uppercase "W" to a lowercase "w" this will still print option C, because the longer string is the pattern, in order to have option D, we also need to switch the strings, the pattern should go to input, and vice versa.

What do you think guys ?!

By the way, how is WHIZLABS, does it make sense to pay attention to their mocks for exam preparation ?!
 
Srikkanth Mohanasundaram
Ranch Hand
Posts: 243
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!! Welcome to Ranch!!!

You are right

Thanks,
Srikkanth
 
Aj Deschanel
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Srikkanth Mohanasundaram wrote:Hello!! Welcome to Ranch!!!

Thanks.
 
Atwal Usha
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aj,

Thank you for bringing this into our notice. After reading your post due action has been taken on this particular question by the content team and we really appreciate your inputs.

The output has nothing to do with the case of the first letter of the string "water" even if it is changed to "Water" the output will result the same and which is Match not Found.

However, if the code is changed to the following then changing "water" to "Water" will change the output to Match Found.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic