Bird
0
0

What will happen if a Kafka consumer uses IntegerDeserializer but the message value is a string "123"?

medium📝 Predict Output Q5 of 15
Kafka - Consumers

What will happen if a Kafka consumer uses IntegerDeserializer but the message value is a string "123"?

AThe message will be deserialized to integer 123 successfully
BThe message value will be null
CA serialization exception will be thrown at runtime
DThe consumer will receive the raw byte array
Step-by-Step Solution
Solution:
  1. Step 1: Understand IntegerDeserializer expects bytes representing an integer

    IntegerDeserializer expects the bytes to be in integer format, not string bytes.
  2. Step 2: Analyze deserialization of string bytes with IntegerDeserializer

    Passing string bytes like "123" causes a serialization exception because format is invalid for integer deserialization.
  3. Final Answer:

    A serialization exception will be thrown at runtime -> Option C
  4. Quick Check:

    Wrong deserializer causes runtime exception [OK]
Quick Trick: Mismatch deserializer and data type causes runtime error [OK]
Common Mistakes:
  • Assuming string "123" converts automatically to integer
  • Expecting null instead of exception
  • Thinking raw bytes are returned

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes