Answer (Choose 1 answer)
What happens when you try to compile and run the following program?
import java.util.*;
public class Main{
public static void main(String argv[]){
Vector<Integer> t = new Vector<Integer>();
t.add(12);
t.add(2);
t.add(6);
t.add(2.4);
Iterator<Integer> i = t.iterator();
int sum=0;
while(i.hasNext()) sum += i.next();
System.out.println(sum);
}
}
A. The program will print out: 20
B. The program will print out: 22
C. The program will print out: 18
D. The program has a compile error.
Save at server failed!. Please inform the supervisor and continue the exam.