adplus-dvertising
frame-decoration

Question

What is the output of this 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<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

Answer: (b).7.0

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?

Similar Questions

Discover Related MCQs

Q. Which of the following is not an Enterprise Beans type?

Q. Which of the following is not true about Java beans?

Q. Which file separator should be used by MANIFEST file?

Q. Which of the following is correct error when loading JAR file with duplicate name?

Q. Java Beans are extremely secured?

Q. Which of the following is not a feature of Beans?

Q. What is the attribute of java bean to specify scope of bean to have single instance per Spring IOC?

Q. Which attribute is used to specify initialization method?

Q. Which attribute is used to specify destroy method?

Q. How to specify autowiring by name?

Q. Which of the following contains both date and time?

Q. Which of the following is advantage of using JDBC connection pool?

Q. Which of the following is advantage of using PreparedStatement in Java?

Q. Which one of the following contains date information?

Q. What does setAutoCommit(false) do?

Q. Which of the following is used to call stored procedure?

Q. Which of the following is used to limit the number of rows returned?

Q. Which of the following is method of JDBC batch process?

Q. Which of the following is used to rollback a JDBC transaction?

Q. Which of the following is not a JDBC connection isolation levels?