Q. What is the output of the following code snippet?
Code:
String s1 = “Hello”; System.out.println(sA)substring(1, 4));
β
Correct Answer: (B)
Hel
Explanation: The substring method in Java can also take two arguments, specifying a start index and an end index for the substring. The substring returned includes the character at the start index, but not the character at the end index. In this case, sA)substring(1, 4) returns “Hel”, which is the substring of s1 starting from index 1 and ending at index C)