Multiple Choice
Consider the following code snippet: ArrayList<Integer> num1 = new ArrayList<Integer>() ;
Int data;
Scanner in = new Scanner(System.in) ;
For (int i = 0; i < 5; i++)
{
Data = in.nextInt() ;
Num1.add(data) ;
If (data == 0 && num1.size() > 3)
{
Num1.remove(num1.size() - 1) ;
}
}
System.out.println("size is : " + num1.size() ) ;
What is the output of the given code snippet if the user enters 1,2,0,0,1 as the input?
A) size is : 1
B) size is : 2
C) size is : 4
D) size is : 0
Correct Answer:

Verified
Correct Answer:
Verified
Q52: Assume the variable numbers has been declared
Q56: Assume the array of integers values has
Q58: Which one of the following code snippets
Q60: Which statement(s) about the size of a
Q62: Which code snippet calculates the sum of
Q63: Which statement is true about the code
Q64: Which statements are true regarding the differences
Q65: Which one of the following statements is
Q66: What will be printed by the statements
Q95: Why is the use of physical objects