Given the code fragment:
What is the result?
Given the code fragment:
What is the result?
Initially, when using `Collections.binarySearch(lst, "e3")` on the unsorted list `[
package q24; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Q24 { public static void main(String[] args) { List lst = new ArrayList(); lst.add("e1"); lst.add("e3"); lst.add("e2"); int x1 = Collections.binarySearch(lst, "e3"); System.out.println(x1); Collections.sort(lst); int x2 = Collections.binarySearch(lst, "e3"); System.out.println(x2); Collections.reverse(lst); int x3 = Collections.binarySearch(lst, "e3"); System.out.println(x3); } } // Result: // 1 // 2 // -4
A is correct answer