31.0k views
0 votes
Consider the following declaration.int[] alpha = new int[3];Which of the following input statements correctly input values into alpha?(i)alpha = cin.nextInt();alpha = cin.nextInt();alpha = cin.nextInt();(ii)alpha[0] = cin.nextInt();alpha[1] = cin.nextInt();alpha[2] = cin.nextInt();1. Only (i)2. Only (ii)3. None of these4. Both (i) and (ii)

User Jkeys
by
5.6k points

1 Answer

1 vote

Answer:

Option (2) i.e., Only (ii) is the correct option to the following question.

Step-by-step explanation:

Here, in the following code that is written in the Java Programming Language in which they set integer data type array variable "alpha" and set its index to 3 through "new" keyword then, we get input from the user in the index 0 then, we get input from the user in the index 1 then, again we repeat this step for index 2. So, that's why the following option is correct.

Option 1 is wrong because in this option the user input only in the index 0 and this is also the wrong way to insert value in the array variable.

User Andrew Rumm
by
5.7k points