Computer Applications

If a string contains 12 characters, what will be the index of the last character?

  1. 12
  2. 11
  3. 10
  4. 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