AllExam Dumps

DUMPS, FREE DUMPS, VCP5 DUMPS| VMWARE DUMPS, VCP DUMPS, VCP4 DUMPS, VCAP DUMPS, VCDX DUMPS, CISCO DUMPS, CCNA, CCNA DUMPS, CCNP DUMPS, CCIE DUMPS, ITIL, EXIN DUMPS,


READ Free Dumps For Oracle- 1z0-804





Question ID 21443

Given the integer implements comparable:
import java.util.*;
public class SortAndSearch2 {
static final Comparator<Integer> IntegerComparator = new Comparator<Integer>() {
public int compare (Integer n1, Integer n2) {
return n2.compareTo(n1);
}
};
public static void main(String args[]) {
ArrayList<Integer> list = new ArrayList<>();
list.add (4);
list.add (1);
list.add (3);
list.add (2);
Collections.sort(list, null);
System.out.println(Collections.binarySearch(list, 3));
Collections.sort(list,IntegerComparator);
System.out.println(Collections.binarySearch(list, 3));
}
}
What is the result?

Option A

4
1

Option B

1
2

Option C

3
2

Option D

2

Option E

2
3

Correct Answer D
Explanation Explanation: binarySearch public static int binarySearch(List> 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. Parameters: list - the list to be searched. key - the key to be searched for. Returns: the index of the search key, if it is contained in the list; otherwise, (-(insertion point) - 1).


Question ID 21444

Which statement declares a generic class?

Option A

public class Example < T > { }

Option B

public class <Example> { }

Option C

public class Example <> { }

Option D

public class Example (Generic) { }

Explanation