What is the result of the following?
int[] random = { 6, -4, 12, 0, -10 }; int x = 12; int y = Arrays.binarySearch(random, x); System.out.println(y);
D.
The code compiles and runs fine.
An array must be sorted for binarySearch()
to return a meaningful result.