Question: Which one of the following code snippets accepts the integer input in an array list named num 1 and stores the even integers of num

Which one of the following code snippets accepts the integer input in an array list named num1 and stores the even integers of num1 in another array list named evennum?
Question 19 options:
ArrayList num1= new ArrayList();
ArrayList evennum = new ArrayList();
Scanner in = new Scanner(System.in);
int data;
for (int i =0; i <10; i++)
{
data = in.nextInt();
num1.add(data);
if (num1.get(i)%2==0)
{
evennum.add(num1.get(i));
}
}
ArrayList num1= new ArrayList();
ArrayList evennum = new ArrayList();
Scanner in = new Scanner(System.in);
int data;
for (int i =0; i <10; i++)
{
data = in.nextInt();
num1.add(data);
if (num1.get(i)%2!=0)
{
evennum.add(num1.get(i));
}
}
ArrayList num1= new ArrayList();
ArrayList evennum = new ArrayList();
Scanner in = new Scanner(System.in);
int data;
for int i =0; i <10; i++)
{
data = in.nextInt();
num1.add(data);
if (num1.get(i)%2!=0)
{
evennum[i]= num1[i];
}
}
ArrayList num1= new ArrayList();
ArrayList evennum = new ArrayList();
Scanner in = new Scanner(System.in);
int data;
for (int i =0; i <10; i++)
{
data = in.nextInt();
num1.add(data);
if (num1.get(i)%2==0)
{
evennum[i]= num1[i];
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!