Bird
Raised Fist0

Given the following Kafka Streams code snippet, what is the output type of customerCounts?

medium📝 Predict Output Q13 of Q15
Kafka - Streams
Given the following Kafka Streams code snippet, what is the output type of customerCounts?
var customerCounts = orders
  .groupBy((key, order) -> order.customerId)
  .count();
AKTable<String, Long>
BKStream<String, Integer>
CKStream<String, Long>
DKTable<String, String>
Step-by-Step Solution
Solution:
  1. Step 1: Understand groupBy and count return types

    Grouping returns a grouped stream, and count() returns a KTable with counts per key.
  2. Step 2: Identify key and value types

    The key is String (customerId), and count returns Long values.
  3. Final Answer:

    KTable<String, Long> -> Option A
  4. Quick Check:

    count() returns KTable with Long values [OK]
Quick Trick: count() after groupBy returns KTable with Long values [OK]
Common Mistakes:
MISTAKES
  • Assuming count returns KStream
  • Confusing Long with Integer type
  • Mixing up KStream and KTable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes