hiexam
oracle · 1z0-829 · Q606 · multiple_choice · topic_1

Given the code fragment: //IMG// What is the result?

Given the code fragment: //IMG// What is the result?
  • A.ABBCDE // the order of elements is unpredictable
  • B.ABCDE
  • C.ABCDE // the order of elements is unpredictable
  • D.ADEABCB // the order of elements is unpredictable
Explanation
Selected Answer: C package q13; import java.util.stream.Stream; public class Q13 { public static void main(String[] args) { Stream<String> s1 = Stream.of("A", "B", "C", "B"); Stream<String> s2 = Stream.of("A", "D", "E"); Stream.concat(s1, s2).parallel().distinct().forEach(element -> System.out.print(element)); } } // Result: // CEDBA // CEDAB // CEDBA

Reference: examtopics_top_comment

Practice with progress tracking

Sign in to track wrong answers, get spaced-repetition reminders, and run timed exam mode.