ExamVeda
Login
Home
This question belongs to Java Program Generics In Java
Generics in Java
?

What will be the output of the following Java program?
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<Integer> li = Arrays.asList(1, 2, 3);
        System.out.println(sumOfList(li));
    }
}

Answer & Solution
Correct Answer: Option D
Let's discuss the solution. Join the discussion
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.