Kafka - ConsumersWhat will happen if you call consumer.subscribe(null); in Kafka?AThe consumer will unsubscribe from all topics.BThe consumer will throw a NullPointerException.CThe consumer will subscribe to all available topics.DThe consumer will ignore the call and keep current subscriptions.Check Answer
Step-by-Step SolutionSolution:Step 1: Check the argument type for subscribe()subscribe() expects a non-null collection of topic names.Step 2: Understand behavior when null is passedPassing null causes a NullPointerException because the method tries to iterate over the collection.Final Answer:The consumer will throw a NullPointerException. -> Option BQuick Check:subscribe(null) causes NullPointerException [OK]Quick Trick: Never pass null to subscribe(); use empty list to unsubscribe [OK]Common Mistakes:Thinking null unsubscribes consumerAssuming null subscribes to all topicsIgnoring that null causes runtime error
Master "Consumers" in Kafka9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Kafka Quizzes Consumer Groups - Consumer group concept - Quiz 14medium Consumers - Auto-commit vs manual commit - Quiz 11easy Consumers - Offset management - Quiz 11easy Kafka Basics and Event Streaming - Kafka CLI tools overview - Quiz 3easy Kafka Cluster Architecture - In-sync replicas (ISR) - Quiz 10hard Kafka Cluster Architecture - ZooKeeper role (and KRaft replacement) - Quiz 1easy Producers - Serialization (String, JSON, Avro) - Quiz 3easy Producers - Producer retries and idempotency - Quiz 11easy Producers - Why producers publish data - Quiz 10hard Topics and Partitions - Partition key and routing - Quiz 2easy