Ask Question

What will be the value of x[8] after the following code has been executed?

final int SUB = 12;

int[ ] x = new int[SUB];

int y = 100;

for (int i = 0; i < SUB; i++)

{

x[i] = y;

y + = 10;

}

+3
Answers (1)
  1. 15 February, 03:45
    0
    The value of x[8] is "180".

    Explanation:

    The description of the code as follows:

    In the given code we declare a variable that is "SUB" this is an integer type variable this variable uses the final keyword that is used to make variable constant and this variable holds a value that is "12". Then define an array that is "x". It is used to store integer values. and in the next line, an integer variable is defined that is "y" which holds value "100" In the loop, we increase all numbers by 10 and stores into an array. when the array size is equal to 8 it will store 180 value.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What will be the value of x[8] after the following code has been executed? final int SUB = 12; int[ ] x = new int[SUB]; int y = 100; for ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers