Developer interest in Kotlin spiked when Google named it an official Android programming language. Released in 2011 by JetBrains, and continually fine-tuned, Kotlin is now up to version 1.2.41, with boosted interoperability with Java, the “original” Android development language. But the rise of Kotlin
doesn’t mean Android developers can (or should) abandon Java entirely. Kotlin leverages Java libraries, provides Java APIs, and integrates with Java frameworks; if you know one language, you should learn the other. During a Kotlin developer interview, you'll inevitably be asked questions about both. When interviewing candidates for a Kotlin-related role, Rimantas Benetis, technology director at Devbridge Group (a Chicago-based custom software, web and mobile app development company), looks for a solid understanding of Kotlin, as well as a straightforward approach to problem-solving. James Baca, a senior Android developer at Bamtech Media, a technology services and video streaming company headquartered in New York City, advises avoiding facile answers by digging deep and illustrating your agility with Kotlin. With that in mind, here are a few sample Kotlin developer interview questions:
"What advantages do you think Kotlin has over Java, and why?" What most people say:
Most people pick some design decisions that they feel are better, such as Kotlin’s nullability declaration requirements, and leave it at that. What you should say:
It avoids answers that most other candidates would say, and shows that you understand the reasons why Kotlin exists in the first place.
"How do you declare variables in Kotlin and how does it differ from its Java counterpart?" What most people say:
Most Kotlin developer interview candidates answer that the syntax is different between Java and Kotlin. In Java, you declare the type first, followed by the variable name; Kotlin does this in reverse and uses a colon. What you should say:
"Besides the obvious syntax differences, Kotlin has two types of variables. They can be declared as read-only, using the ‘val’ keyword, or mutable using the ‘var’ keyword. Java doesn't have read-only variables. Instead, you have to make the variable private and add a public getter to enforce read-only. Also, and arguably most important, is that you have to decide if the variable can contain nulls in Kotlin." Why you should say it:
This answer shows that you understand how to use the data encapsulation features of Kotlin, which indicates that you understand the importance of one of the four object-oriented programming principles.
"It also shows that you know you need to decide if a variable should be null," Baca noted. "And, by discussing declarative null syntax, you demonstrate that you are implicitly aware of ‘The Billion Dollar Mistake,’
more commonly referred to as NPE or Null Pointer Exception, and how to avoid it."
"What is the difference between ‘const’ and ‘val’?" What most people say:
“There is no difference. ‘Const’ and ‘val’ are the same.” What you should say:
"’Const’ is a compile time constant that never changes. ‘Val,’ on the other hand, is a variable with a caveat, which is that it’s a read-only variable. It's possible that its value will change. However, it doesn't have a setter for directly changing the value." Baca also recommended giving an example: "In the sample below, see that ‘isEmpty’ is read-only, but its value can change." val isEmpty: Boolean get() = this.size == 0 Why you should say it:
The answer shows you know how to take advantage of the simple-yet-powerful language features in Kotlin.
"Explain the data classes used in Kotlin and why they are useful." What most people say:
“It's a time-saver. They are just plain Java objects that have equals() predefined so that you don’t have to write boilerplate equals code for every new class.” What you should say:
"Data classes have several benefits. They auto-generate equals()/hashCode() functions, a very readable toString() output, and componentN() functions to take advantage of destructuring declarations, as well as copy method for generating copies of the class." Why you should say it:
"While the first answer is sort of acceptable, it doesn’t show all of the time-saving features," Baca said. Keep that in mind during your next Kotlin developer interview.