aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes k&b scjp5,  page no 616, problem no 9 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "k&b scjp5,  page no 616, problem no 9" Watch "k&b scjp5,  page no 616, problem no 9" New topic
Author

k&b scjp5, page no 616, problem no 9

Mukesh Gulia
Greenhorn

Joined: Sep 09, 2008
Posts: 2
Given a properly prepared String array containing five elements, which range of results could a proper invocation of Arrays.binarySearch()produce?

a. 0 through 4
b. 0 through 5
c. -1 through 4
d. -1 through 5
e. -5 through 4
f. -5 through 5
g. -6 through 4
h. -6 through 5

ans is G.
i thought answer is be E

range can be ((-5) -1) through 4 i.e. 4 to 4
negative result give insertion point(array index).
please confirm.
Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
If you know

range can be ((-5) -1) through 4 i.e. 4 to 4


then range is -6 to 4.
sweety sinha
Ranch Hand

Joined: Jul 07, 2008
Posts: 76

............................................................................

range can be ((-5) -1) through 4 i.e.
((-5)+(-1))= (-5-1)= -6
i.e range can be -6 through 4

you did a slight mistake in adding.
Mukesh Gulia
Greenhorn

Joined: Sep 09, 2008
Posts: 2
yeah yeah
thanks all
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: k&b scjp5, page no 616, problem no 9