Q. What is the output of the following code snippet?
Code:
String s1 = “Hello”; int i = 10; System.out.println(sA)charAt(i));
β
Correct Answer: (A)
IndexOutOfBoundsException
Explanation: If the index specified in the charAt method is greater than or equal to the length of the string, an IndexOutOfBoundsException is thrown.