Solved

Which One of the Following Code Snippets Accepts the Integer

Question 50

Multiple Choice

Which one of the following code snippets accepts the integer input in an array named num1 and stores the odd integers of num1 in another array 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:

verifed

Verified

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

Related Questions