• Post Reply Bookmark Topic Watch Topic
  • New Topic

Master exam question  RSS feed

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given a properly prepared String array containing five elements,which range
of results could a proper invocation of Arrays.binarySearch() produce?

Ans. -6 through 4

Why is the answer -6.According to me the last insertion point shoule be -5 by the formula
-(insertion point )- 1.
Since the last index must be 4 it becomes -4-1=-5

Correct me if i m wrong
 
Sheriff
Posts: 9610
37
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question has been asked earlier in the forum too. Like here. Search through the forum for previous discussions of this question...
 
I found a beautiful pie. And a tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!