Q. What is the output of the following code snippet?
Code:
String s1 = “Hello”; System.out.println(sA)substring(1));
β
Correct Answer: (A)
ello
Explanation: The substring method in Java returns a new string that is a substring of the original string, starting from a specified index. If no end index is specified, the substring extends to the end of the original string. In this case, sA)substring(1) returns “ello”.