### Question:
Utils { public static int binarySearch(int[] index, int key, int begin, int end) { end--; while (begin <= end) { int mid = (end + begin) >> 1; if (index[mid] < key) { begin = mid + 1; } else if (index[mid] > key) { end = mid - 1; } else { return mid; } } return -1; }  static int binarySearch(int[] index, int key, int begin, int end); static int myBinarySearch(int[] indices, int key, int begin, int end);  }### Answer:
@Test public void testBinarySearch() { System.out.println("binarySearch"); int[] index = {10, 11, 12, 13, 14}; int key = 12; int begin = 0; int end = 5; int expResult = 2; int result = Utils.binarySearch(index, key, begin, end); assertEquals(expResult, result); }
@Test public void testBinaryLast() { System.out.println("binarySearch"); int[] index = {10, 11, 12, 13, 14}; int key = 14; int begin = 0; int end = 5; int expResult = 4; int result = Utils.binarySearch(index, key, begin, end); assertEquals(expResult, result); }
@Test public void testBinarySearchNotFound() { System.out.println("binarySearch"); int[] index = {10, 13, 15, 17, 19}; int key = 14; int begin = 0; int end = 5; int expResult = -1; int result = Utils.binarySearch(index, key, begin, end); assertEquals(expResult, result); }