The output from the following code is 123 because substring takes from beginIndex to EndIndex - 1. However, I am surprised how char
123
substring
char
so substring's function declaration looks like substring(int startIndex, int endIndex). Now when you pass char it is automatically promoted to integer (endIndex) and hence treated as int.