Here are the packages which need to import in Java/Scala. import org.apache.kafka.clients.consumer.ConsumerRecord import org.apache.kafka.common.serialization.StringDeserializer import org.apache.spark.streaming.kafka010._ import org.apache.spark.streaming.kafka010.LocationStrategies.PreferConsistent import org.apache.spark.streaming.kafka010.ConsumerStrategies.Subscribe A must-know for anyone looking for top Kafka interview questions, this is one of the frequently asked interview questions on Kafka.