113k views
4 votes
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}}


What is the value of vals[4][1] in the array above?

1. 7.1
2. There is no such value.
3. 7.3
4. 1.1

2 Answers

4 votes

Answer:

2) There is no such value.

Step-by-step explanation:

since java uses 0 as the first digit of any value, the value vals[4][1] is calling the 5th and 2nd number of the 2D array. To get 7.1 the value needed would be vals[3][0]. 7.3 is vals[3][1], and 1.1 vals[0][0].

You can test this by doing,
System.out.println(vals[?][?]);

Where,
System.out.println(vals[4][1]);
Will give you an error because "There is no such value."

User Shauntee
by
7.4k points
1 vote

Answer:

Option 3 i.e., 7.3 is the correct answer to the following question.

Step-by-step explanation:

In the following two dimensional array that is the double data type 2-D array variable "val" and it contains some float type information in the form of matrix that has 4 rows and 3 columns, In the following statement, they asked the value of 4th row and 2nd column and in the matrix 4th row and 2nd column contain the value i.e., 7.3.

User Ali Kianinejad
by
7.4k points