A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
OCA Java SE 8 Programmer I Study Guide
this week in the
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
I agree. Here's the link:
subject: Master exam question
chapter 7: K&B
Binary Search doubt
k&b scjp5, page no 616, problem no 9
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015