Consider the below code snippet:

import java.util.ArrayList;
import java.util.stream.Collectors;
public class CollectionStream {
public static void main(String[] args) {
ArrayList list=new ArrayList<>();
list.add(12.0);
list.add(35.0);
list.add(40.0);
Double sumPrices = list.stream() .collect(Collectors.summingDouble(x->x));
System.out.println("Sum : "+sumPrices);
Integer sumId = list.stream().collect(Collectors.
summingInt(x->x.intValue()));
System.out.println("Sum: "+sumId);
Double avgId =list.stream().collect(Collectors.
averagingDouble(x->x));
System.out.println("Avg: "+avgId);
}
}
What is the output when it is executed?

Sum: 87
        Sum: 87
        Avg: 29
Sum: 87.0
        Sum: 87
        Avg: 29.0
Compilation error occurs
Runtime exception
Verified Answer
Correct Option - b

To get all Infosys Certified Java SE8 Professional Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in