Kafka's subscribe() expects a collection of topic names, such as a List or Set.
Step 2: Validate each option
consumer.subscribe(Collections.singletonList("orders")); uses Collections.singletonList which is a valid List containing "orders". The other options use incorrect argument types or syntax.
Final Answer:
consumer.subscribe(Collections.singletonList("orders")); -> Option B
Quick Check:
subscribe() needs a collection of topics [OK]
Quick Trick:Use a list or set to subscribe to topics [OK]
Common Mistakes:
Passing a single string instead of a collection
Using array syntax not supported in Java
Adding extra text like 'topic=' in topic name
Master "Consumers" in Kafka
9 interactive learning modes - each teaches the same concept differently