427 views
5 votes
What is the value of alpha[3] after the following code executes?

int[] alpha = new int[5];int j;for (j = 4; j >= 0; j--){alpha[j] = j + 5;if (j <= 2)alpha[j + 1] = alpha[j] + 3;}1. 9
2. 5
3. 8
4. 10

User Steinbock
by
6.7k points

1 Answer

0 votes

Answer:

Option (4) i.e., 10 is the correct answer to the following question.

Step-by-step explanation:

Here, in the following question that is written in the Java Programming Language in which they set an integer data type array variable "alpha" and pass index value 5 then 3. Set the for loop which is starets from 4 to 0 in reverse order then, initialize the value of the variable "j + 5" in the array variable alpha then, check condition if j is less than equal to 2 then perform calculation "alpha[j + 1] = alpha[j] + 3".