Ask Question
13 March, 04:55

Consider the following declaration. int[] beta = new int[3]; int j; Which of the following input statements correctly input values into beta? (Assume that cin is a Scanner object initialized to the standard input device.) (i) beta[0] = cin. nextInt (); beta[1] = cin. nextInt (); beta[2] = cin. nextInt (); (ii) for (j = 0; j < 3; j++) beta[j] = cin. nextInt ();

+1
Answers (1)
  1. 13 March, 07:51
    0
    The answer is "Option (i) and (ii) ".

    Explanation:

    In the given java code an integer array that is "beta" defines that contains 3 elements. To insert element in by user input we use scanner class object that is "cin". In the given question two options are defined that is used for inserting elements in array but there is a minor difference between them that can be described as:

    In option (i), To insert an element in array we use index value. It is time taking. In option (ii), In this option use a loop, inside a loop we write only one line, and this line inserts elements in array automatically.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Consider the following declaration. int[] beta = new int[3]; int j; Which of the following input statements correctly input values into ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers