A

Admin • 828.03K Points
Coach

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

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

Explanation by: Admin
The substring method in Java returns a substring of a string, starting from a specified index. In this case, sA)substring(2) returns “llo”, which is the substring of s1 starting from index B)

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.