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:
Verified
Q56: Which one of the following statements is
Q57: Consider the following code snippet: String[] data
Q58: What is the output of the following
Q59: Consider the following code snippet:
Int[][] arr =
{
{
Q60: Consider the following code snippet in Java
Q62: Consider the following code snippet: public static
Q63: Consider the following code snippet: ArrayList<Integer> arrList
Q90: Which one of the following statements about
Q91: What is the result of the following
Q96: Your program needs to store an integer
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents