109k views
4 votes
What is the value of vals[4][1]? double[][] vals = {{1.1, 1.3, 1.5}, {3.1, 3.3, 3.5}, {5.1, 5.3, 5.5}, {7.1, 7.3, 7.5}};

User Zubo
by
3.9k points

1 Answer

7 votes

Answer:

When the user concludes the value of "vals[4][1]", then it will give an exception of "ArrayIndexOutOfBoundsException".

Step-by-step explanation:

  • It is because the size of the above array is [4*3] which takes the starting index at [0][0] and ending index at [3][2]. It is because the array index value starts from 0 and ends in (s-1).
  • When the double dimension array size is [5][5], then it will conclude the value of [4][1].
  • The above array have following index which value can be calculated :-- [0][0],[0][1],[0][2],[1][0], [1][1],[1][2], [2][0], [2][1], [2][2],[3][0],[3][1] and [3][2].
User Montrealmike
by
3.8k points