Exception Handling With String Substring
What does the program print when executed?
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
RuntimeException
B
IndexOutOfBoundsException
C
StringIndexOutOfBoundsException
D
NullPointerException
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE