A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Programmer Certification (SCJP/OCPJP)
Master exam question
Joined: Mar 20, 2010
May 07, 2010 00:05:20
Given a properly prepared
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
Joined: Aug 03, 2008
May 07, 2010 00:22:15
This question has been asked earlier in the forum too. Like
. Search through the forum for previous discussions of this question...
SCJP 6 | SCWCD 5 |
Javaranch SCJP FAQ
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
subject: Master exam question
chapter 7: K&B
Kathy Sierra doubt
Binary Search doubt
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014