What is the result?

Given the code fragment:List<String> codes = Arrays.asList (“DOC”, “MPEG”, “JPEG”);
codes.forEach (c -> System.out.print(c + “ “));
String fmt = codes.stream()
.filter (s-> s.contains (“PEG”))
.reduce((s, t) -> s + t).get();
System.out.println(“\\n” + fmt);
What is the result?

Given the code fragment:List<String> codes = Arrays.asList (“DOC”, “MPEG”, “JPEG”);
codes.forEach (c -> System.out.print(c + “ “));
String fmt = codes.stream()
.filter (s-> s.contains (“PEG”))
.reduce((s, t) -> s + t).get();
System.out.println(“\\n” + fmt);
What is the result?

A.
DOC MPEG JPEG
MPEGJPEG

B.
DOC MPEG MPEGJPEG
MPEGMPEGJPEG

C.
MPEGJPEG
MPEGJPEG

D.
The order of the output is unpredictable.



Leave a Reply 3

Your email address will not be published. Required fields are marked *


smh

smh

A.
DOC MPEG JPEG
MPEGJPEG