Multiple choice

Given the following code snippet; int salaries[]; int index = 0; salaries = new int salaries[4]; while (index < 4) { salaries[index] = 10000; index++; } What is the value of salaries [3]?

  1. 40000

  2. 50000

  3. 15000

  4. 10000

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The while loop iterates 4 times (index 0, 1, 2, 3). Each iteration assigns 10000 to salaries[index]. After index=3 iteration, salaries[3] = 10000. The array doesn't accumulate values - each position gets exactly 10000. This is assignment, not addition. Option D is correct.