Bird
Raised Fist0

Which of the following is the correct way to apply a map transformation in Kafka Streams using Java?

easy📝 Syntax Q12 of Q15
Kafka - Streams
Which of the following is the correct way to apply a map transformation in Kafka Streams using Java?
Astream.reduce((v1, v2) -> v1 + v2)
Bstream.filter(value -> value.length())
Cstream.mapValues(value -> value.toUpperCase())
Dstream.collect(Collectors.toList())
Step-by-Step Solution
Solution:
  1. Step 1: Identify the map transformation syntax

    In Kafka Streams, mapValues applies a function to each value, e.g., converting to uppercase.
  2. Step 2: Match the correct syntax

    stream.mapValues(value -> value.toUpperCase()) uses mapValues with a lambda toUpperCase(), which is correct.
  3. Final Answer:

    stream.mapValues(value -> value.toUpperCase()) -> Option C
  4. Quick Check:

    map transformation syntax = mapValues with lambda [OK]
Quick Trick: Map uses mapValues with a function on values [OK]
Common Mistakes:
MISTAKES
  • Using filter instead of map
  • Using reduce for mapping
  • Using collect which is not a stream operation here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes