Multiple choice technology programming languages

For Arrays & Collection, Sort order & search order need not to be SAME.

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

For binary search to work correctly in Java, the collection must be sorted using the same ordering (natural or comparator) that will be used for the search. If you sort with one comparator and search with another, binarySearch() behavior is undefined and results will be incorrect.