Ask Question
3 March, 12:20

Consider the following declaration: double[] sales = new double[50]; int j; Which of the following correctly initializes all the components of the array sales to 10.

(i) for (j = 0; j < 49; j++) sales[j] = 10;

(ii) for (j = 1; j < = 50; j++) sales[j] = 10;

+4
Answers (1)
  1. 3 March, 12:35
    0
    The answer is "None of these".

    Explanation:

    In the given question an array "sales[]" is declared, which contains 50 double type elements, and in the next line, an integer variable j is defined, which uses a for loop. In this question two options is given, in which both are not correct, that can be described as follows:

    In option (i), A loop is defined that, uses variable j which starts with 0 and ends with 48, So total elements are 48 that's why it is not correct. In option (ii), A loop will use variable j that, starts with 1 and ends with 49, That's why it is not correct.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Consider the following declaration: double[] sales = new double[50]; int j; Which of the following correctly initializes all the components ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers