Q. What will be the output?
String str1 = "abcde";
System.out.println(str1.substring(1, 3));
β
Correct Answer: (B)
bc
Explanation: substring() method has two variants and returns a new string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string or upto endIndex - 1 if second argument is given.