Collections and Generics
© examsiri.com
Question : 16 of 53
Marks:
+1,
-0
Given a pre-generics implementation of a method:
Which three changes must be made to the method sum to use generics?(Choose three.)
1. public static int sum(List list) {
2.   int sum = 0;
3.   for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
4.    int i = ((Integer)iter.next()).intValue();
5.    sum += i;
6.   }
7.   return sum;
8. }Which three changes must be made to the method sum to use generics?(Choose three.)
Go to Question: