Computer Applications
If a string contains 12 characters, what will be the index of the last character?
- 12
- 11
- 10
- 0
Java String Handling
22 Likes
Answer
11
Reason — A String data type manages character array for storing a string character-wise starting from 0th subscript. Hence, the index number of the characters starts from 0 (zero) and ends with (k-1), if k is length of the string. Hence, the last index will be 11 (12-1), as 12 is the size of the string.
Answered By
10 Likes
Related Questions
A string is:
- A set of letters
- A set of letters and digits
- A set of letters, digits and special characters
- All the above
A string internally creates:
- An integer array
- A numeric array
- A character array
- A double type array
What will be the value stored in the variable 'c' if the following statement is executed?
c = "COMPUTER".charAt("COMPUTER ".indexOf('P'))- 3
- 4
- P
- M
Which of the following functions is used to remove leading and trailing white spaces from the string?
- trim( )
- trail( )
- truncate( )
- slice( )