A

Admin • 832.27K Points
Coach

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

Code:
String s1 = “Hello”;
System.out.println(sA)charAt(2));
  • (A) H
  • (B) e
  • (C) l
  • (D) None of the above
  • Correct Answer - Option(C)
  • Views: 27
  • 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”, which is the character at index B)

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.