Bird
Raised Fist0

Given this Kafka Streams code snippet, what is the output if the input stream has values [1, 2, 3]?

medium📝 Predict Output Q4 of Q15
Kafka - Streams
Given this Kafka Streams code snippet, what is the output if the input stream has values [1, 2, 3]?
stream.map(value -> value * 2)
A[0, 1, 2]
B[2, 4, 6]
C[1, 2, 3]
D[1, 4, 9]
Step-by-Step Solution
Solution:
  1. Step 1: Understand the map transformation

    The map function multiplies each input value by 2.
  2. Step 2: Apply the transformation to each input value

    1*2=2, 2*2=4, 3*2=6, so output is [2, 4, 6].
  3. Final Answer:

    [2, 4, 6] -> Option B
  4. Quick Check:

    map(value * 2) output = [2,4,6] [OK]
Quick Trick: map() applies function to each value, changing output accordingly [OK]
Common Mistakes:
MISTAKES
  • Assuming map() does not change values
  • Confusing map() with filter()
  • Calculating squares instead of doubling

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes