πŸ“Š JAVA
Q. What is the output of the following code snippet?
Code:
String s1 = “Hello”;
int i = 10;
System.out.println(sA)charAt(i));
  • (A) IndexOutOfBoundsException
  • (B) Error
  • (C) null
  • (D) None of the above
πŸ’¬ Discuss
βœ… 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.

Explanation by: Kirti
If the index specified in the charAt method is greater than or equal to the length of the string, an IndexOutOfBoundsException is thrown.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
268
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Kirti
Publisher
πŸ“ˆ
99%
Success Rate