Since because at runtime you assign the array "b" to "a" and taking the new array (b)'s index value to be used as the index to the original array "a", one of the values present in the "b" array (8) is causing an ArrayIndexOutOfBoundsException.
I have a doubt in the output especially in the second SOP.
As per the dynamic array assignment (b to a) before accessing the index of original array "a", the second statement should give the value "1" because b is 3 and when it becomes an index of "a", a is 1.
It gives the correct value "1" in the output when its being run alone.
But when its being run along with the first SOP, it gives the value "2".