aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Master exam question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Master exam question" Watch "Master exam question" New topic

Master exam question

ujjawal rohra
Ranch Hand

Joined: Mar 20, 2010
Posts: 105
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

Ankit Garg

Joined: Aug 03, 2008
Posts: 9327

This question has been asked earlier in the forum too. Like here. Search through the forum for previous discussions of this question...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Master exam question