This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Master exam question" Watch "Master exam question" New topic
Author

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


SCJP 6
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9400
    
  20

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
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Master exam question
 
It's not a secret anymore!