How many lines does this code output?
List<String> list = new LinkedList<>(); list.add("A"); list.add("B"); list.stream().forEach(System.out.println); list.stream().forEach(System.out.println);
C.
Calling two different streams is allowed.
The code attempts to use a method reference when calling the forEach()
method.
It does not use the right syntax for a method reference.
A double colon needs to be used.
The code would need to be changed to System.
out::println to work and print two lines for each call.
Since it does not compile, Option C is correct.