1(xiii)
The index(subscript) of the last element of an array ar[] is:
- (a)ar.length()
- (b)ar[].length
- (c)ar.length() – 1
- (d)ar.length – 1
Show SolutionHide Solution↓
ar.length – 1
Reason — In Java, the length of an array ar is given by ar.length (without parentheses). Since array indexing starts from 0, the last element's index is always one less than the total length of the array. Therefore, the index of the last element is ar.length – 1.