Question 197 / 297:  What is the result of compiling and running the following code?
import java.util.Arrays;

public class Tester {

public static void main(String[] args) {

String[] arr = { "java", "champ", "you" };

System.out.print(Arrays.binarySearch(arr, "java"));

System.out.print(Arrays.binarySearch(arr, "You"));

}

}

A  02
B  0-1
C  13
D  the result is unpredictable
E  compilation error
<< First < Previous Next > Last >>
Explanation:

Array arr is not sorted, and attempting to search an array or collection, which is not sorted will cause an unpredictable search result.

Exam Home Page
Ask
Yacoub Jayoghli
Start Quiz
Jugnu Khan
Start Quiz
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>