String s = "abcdef";
System.out.println(s.substring(1, 7));What happens?
- A
Prints bcdef
- Bcheck_circle
StringIndexOutOfBoundsException
- C
Prints abcdef
- D
Prints abcd
Explanation
substring(begin, end) requires end <= length(). Length is 6, so end=7 throws StringIndexOutOfBoundsException.