What will be the output of the following Java program? [code] import java.util.*; class Output { public static double

What will be the output of the following Java program?
Code:
    import java.util.*;
    class Output
    {
        public static double sumOfList(List<? extends Number> list) 
        {
            double s = 0.0;
            for (Number n : list)
                s += n.doubleValue();
            return s;
        }
        public static void main(String args[])
        {
           List<Double> ld = Arrays.asList(1.2, 2.3, 3.5);
           System.out.println(sumOfList(ld));
        }
    }
A. 5.0
B. 7.0
C. 8.0
D. 6.0
 

Tìm kiếm

Back
Top