Computer Applications
A single dimensional array contains 37 elements. Which of the following represents the index of its second-to-last element.
Java Arrays
1 Like
Answer
35
Reason — In Java, arrays use zero-based indexing. For an array with 37 elements, the indices range from 0 to 36:
- The last element is at index
36. - The second-to-last element is at index
35(36 - 1).
Answered By
1 Like
Related Questions
Define a class to accept values into an integer array of order 4 x 4 and check whether it is a DIAGONAL array or not. An array is DIAGONAL if the sum of the left diagonal elements equals the sum of the right diagonal elements. Print the appropriate message.
Example:
3 4 2 5
2 5 2 3
5 3 2 7
1 3 7 1Sum of the left diagonal element = 3 + 5 + 2 + 1 = 11
Sum of the right diagonal element = 5 + 2 + 3 + 1 = 11
Name the below structure:

- One dimensional array
- Two Dimensional array with 4 rows and 5 columns
- Three dimensional array
- Two Dimensional array with 5 rows and 4 columns