Ask Question
8 March, 17:54

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

+3
Answers (1)
  1. 8 March, 19:15
    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 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