A

Admin • 828.03K Points
Coach

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
  • Correct Answer - Option(A)
  • Views: 9
  • Filed under category Java
  • Hashtags:

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

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.