A

Admin • 828.03K Points
Coach

Q. What is the output of the following code snippet?

Code:
String s1 = “Hello”;
int i = 2;
System.out.println(sA)charAt(i));
  • (A) l
  • (B) e
  • (C) Error
  • (D) None of the above
  • Correct Answer - Option(A)
  • Views: 15
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
The charAt method in Java returns the character at a specified index in a string. In this case, sA)charAt(2) returns ‘l’.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.