Solved

Which One of the Following Code Snippets Accepts the Integer

Question 61

Multiple Choice

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?


A) ArrayList<Integer> num1 = new ArrayList<Integer>() ;
ArrayList<Integer> evennum = new ArrayList<Integer>() ;
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) ) ;
}
}
B) ArrayList<Integer> num1 = new ArrayList<Integer>() ;
ArrayList<Integer> evennum = new ArrayList<Integer>() ;
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) ) ;
}
}
C) ArrayList<Integer> num1 = new ArrayList<Integer>() ;
ArrayList<Integer> evennum = new ArrayList<Integer>() ;
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];
}
}
D) ArrayList<Integer> num1 = new ArrayList<Integer>() ;
ArrayList<Integer> evennum = new ArrayList<Integer>() ;
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];
}
}

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents