A developer has defined the StrVar variable of type String. Which expression should the developer use to return four characters starting with the second character?
A developer has defined the StrVar variable of type String. Which expression should the developer use to return four characters starting with the second character?
To return four characters starting with the second character in a string, the appropriate method to use is StrVar.Substring(1, 4). This is because string indices in most programming languages are zero-based, meaning the first character is at index 0. To start from the second character, you begin at index 1 and specify the number of characters to include, which is 4 in this case.
I agree. Answer should be A, the second character starts with index 1
Option should be as A because indexing starts like 0,1,2..and so on hence index 1 will represent the second character of the string and need four characters so StrVar.Substring(1,4) is the correct option to go with.