The array must be sorted (as by the sort(byte) method) prior to making this call. If it is not sorted, the results are undefined.
Notice that "undefined" is not the same as "random." That's why you see deterministic behavior and always get 2. However, a future (or past or different) JDK implementation is free to return anything in this scenario. Hence undefined. This is an important distinction to notice so you get this question right on the exam.
With this particular array, you get lucky that 2 is always returned because of the implementation. It first checks the midpoint and gets a match so returns 2. But try this example:
It doesn't print 1 which shows that sorting is in fact important. Hence an undefined result.
Long story short, it just so happens that the undefined result is 2 in the example in the book!