Exception Handling With String Substring
What is printed as a result of executing the following code segment?
public class Main {
public static void main(String[] args) {
String s = "immutable";
try {
System.out.println(s.substring(-1, 3));
} catch (Exception e) {
System.out.println(e.getClass().getSimpleName());
}
}
}
A
IndexOutOfBoundsException
B
StringIndexOutOfBoundsException
C
NullPointerException
D
RuntimeException
Question Leaderboard
Not enough data yet to show leaderboard.
