Which one of the following code snippets accepts the integer input in an array list named num1 and stores the odd integers of num1 in another array list named oddnum?
A) ArrayList<Integer> num1 = new ArrayList<Integer>() ;
ArrayList<Integer> oddnum = new ArrayList<Integer>() ;
Int data;
Scanner in = new Scanner(System.in) ;
For (int i = 0; i < 10; i++)
{
Data = in.nextInt() ;
Num1.add(data) ;
If (num1.get(i) % 2 == 0)
{
Oddnum.add(num1.get(i) ) ;
}
}
B) ArrayList<Integer> num1 = new ArrayList<Integer>() ;
ArrayList<Integer> oddnum = new ArrayList<Integer>() ;
Int data;
Scanner in = new Scanner(System.in) ;
For (int i = 0; i < 10; i++)
{
Data = in.nextInt() ;
Num1.add(data) ;
If (num1.get(i) % 2 != 0)
{
Oddnum.add(num1.get(i) ) ;
}
}
C) ArrayList<Integer> num1 = new ArrayList<Integer>() ;
ArrayList<Integer> oddnum = new ArrayList<Integer>() ;
Int data;
Scanner in = new Scanner(System.in) ;
For (int i = 0; i < 10; i++)
{
Data = in.nextInt() ;
Num1.add(data) ;
If (num1.get(i) % 2 == 0)
{
Oddnum.add(num1[i]) ;
}
}
D) ArrayList<Integer> num1;
ArrayList<Integer> oddnum = new ArrayList<Integer>() ;
Int data;
Scanner in = new Scanner(System.in) ;
For (int i = 0; i < 10; i++)
{
Data = in.nextInt() ;
Num1.add(data) ;
If (num1[i] % 2 != 0)
{
Oddnum.add(num1[i]) ;
}
}
Correct Answer:
Verified
Q32: It may be necessary to "grow" an
Q38: Consider using a deck of cards as
Q41: Which one of the following statements is
Q42: Select the statement that reveals the logic
Q45: Consider the following code snippet:
Int cnt =
Q47: Is there any thing wrong with the
Q48: Consider the following 2-dimensional array. Select the
Q73: Which one of the following statements is
Q74: How many elements can be stored in
Q82: Java 7 introduced enhanced syntax for declaring
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