Computer Applications
The index(subscript) of the last element of an array ar[] is:
- ar.length()
- ar[].length
- ar.length() – 1
- ar.length – 1
Java Arrays
8 Likes
Answer
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.
Answered By
4 Likes
Related Questions
Assertion (A): In switch case, break statement avoids fall through.
Reason (R): break statement helps to execute only one case at a time.
- Both (A) and (R) are true and (R) is a correct explanation of (A).
- Both (A) and (R) are true and (R) is not a correct explanation of (A).
- (A) is true and (R) is false.
- (A) is false and (R) is true.
A physical education teacher asks the students to do the side stretch as shown below, 10 times. Which programming construct the teacher uses?

- if
- switch
- for
- if else if
Assertion (A): A clock is a real-life example of nested loops.
Reason (R): The hour hand moves through 12 positions, while the minute hand moves through 60 positions within each hour.
- Both (A) and (R) are true and (R) is a correct explanation of (A).
- Both (A) and (R) are true and (R) is not a correct explanation of (A).
- (A) is true and (R) is false.
- (A) is false and (R) is true.
Which of the following pairs of methods will cause a compile-time error due to incorrect method overloading?
- void test(int a, int b) and void test(double a, double b)
- void test(int a, double b) and void test(double a, int b)
- void test(int a, double b) and void test(int a)
- void test(int a) and int test(int a)