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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 103
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: 9280
    
  17

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Master exam question
 
Similar Threads
BinarySearch()
chapter 7: K&B
generics doubt
Kathy Sierra doubt
Binary Search doubt