Q. What is the output of the following code snippet?
Code:
String s1 = “Hello”; System.out.println(sA)substring(1, 3));
β
Correct Answer: (A)
el
Explanation: The substring method in Java can also take a second parameter, which specifies the end index of the substring (exclusive). In this case, sA)substring(1, 3) returns “el”.