It would not compile due to 'Index Out Of Bounds Exception',
It does compile. You get a runtime Exception when you try to execute the code.
System.out.println("hello".substring(5));
Eventually, the question is that how is this possible that we can reach this index we should not?
Read the API for the substring(...) method. It explains how the method works and what the parameter means.
In this case it returns an empty String.