nerdexam
Oracle

1Z0-804 · Question #29

Given the integer implements comparable: What is the result?

The correct answer is D. 2. public static <T> int binarySearch(List<? extends Comparable<? super T>> list, T key) Searches the specified list for the specified object using the binary search algorithm. The list must be sorted into ascending order according to the natural ordering of its elements (as by…

Generics and Collections

Question

Given the integer implements comparable:

What is the result?

Exhibit

1Z0-804 question #29 exhibit

Options

  • A4
  • B1
  • C3
  • D2
  • E2

How the community answered

(29 responses)
  • A
    3% (1)
  • B
    3% (1)
  • D
    79% (23)
  • E
    14% (4)

Explanation

public static <T> int binarySearch(List<? extends Comparable<? super T>> list, T key) Searches the specified list for the specified object using the binary search algorithm. The list must be sorted into ascending order according to the natural ordering of its elements (as by the sort(List) method) prior to making this call. If it is not sorted, the results are undefined. list - the list to be searched. key - the key to be searched for. the index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1).

Topics

#Comparable#Integer comparison#compareTo#natural ordering

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice