Home » JAVA Programming » Generics » Question
  1. What is the output of this program?
    import java.util.*;
    public class Result
    {
    public static double sumOfList(List list)
    {
    double var = 0.0;
    for (Number num : list)
    var += num.doubleValue();
    return var;
    }
    public static void main(String args[])
    {
    List obj = Arrays.asList(4.3, 5.6, 7.8);
    System.out.println(sumOfList(obj));
    }
    }
    1. 17.7
    2. 4.3
    3. 5.6
    4. 7.8
    5. None of these
Correct Option: A

17.7



Your comments will be displayed only after manual approval.