Ask Question

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 ();

+5
Answers (1)
  1. 23 July, 20:18
    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?
Find 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 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