Yes, it would compile without any errors. Maybe a really good compiler could look at the code and give an error or warning, but none that I know of. Normally code uses a variable as an index instead of hardcoding values like above:
int[] intA = new int[2]; // has 2 elements: valid indexes are: 0 and 1
// ...
int ix = 3; // will be index that is out of bounds
// then many statements later
intA[ix] = 4; // ERROR: 3 is out of bounds
How come it lets my program compile and lets the user enter the integers before showing the error?
That's the way programs work. It is up to the programmer to write code to detect when an index is out of bounds and not use it.