Questions
Kotlin questions
Choose a question page, learn the concept, then test your understanding with a quiz.
Java Static Methods in Kotlin: Equivalents and Best Practices
Learn how Kotlin replaces Java static methods using top-level functions, companion objects, and objects with clear examples.
Kotlin Constants: Recommended Ways to Declare and Name Them
Learn how to create constants in Kotlin, when to use const val vs val, and the standard naming conventions with clear examples.
Kotlin Double-Bang Operator (!!): Meaning, Null Safety, and Safer Alternatives
Learn what Kotlin's !! operator means, when it throws NullPointerException, and which safer null-handling options to use instead.
Kotlin Property Initialization: by lazy vs lateinit
Learn when to use Kotlin by lazy or lateinit for property initialization, with examples, differences, mistakes, and practical guidance.
Kotlin Ternary Conditional Operator Equivalent Explained
Learn the Kotlin equivalent of the ternary conditional operator and how to use if as an expression with clear examples.
Kotlin const vs val: What’s the Difference?
Learn the difference between const and val in Kotlin, when to use each, and common mistakes with clear examples.
Passing Functions as Parameters in Kotlin
Learn how to pass a function as a parameter in Kotlin using function references, lambdas, and matching function types.
Room Persistence Library Auto-Increment Primary Key in Kotlin
Learn how to create an auto-increment primary key in Room using Kotlin, with @PrimaryKey(autoGenerate = true) examples and common mistakes.
Sort by Multiple Fields in Kotlin: sortedBy, thenBy, and compareBy
Learn how to sort a list by multiple fields in Kotlin using compareBy, thenBy, and sortedWith with clear examples and common pitfalls.
What to Use Instead of Deprecated Handler() in Android Kotlin
Learn why Handler() is deprecated in Android Kotlin and how to replace it with Handler(Looper), coroutines, or view.postDelayed().
Why Kotlin Smart Cast Fails on Mutable Properties: var, Null Safety, and Elegant Fixes
Learn why Kotlin smart cast fails on mutable properties and how to fix it safely using local vals, safe calls, and null handling.
var vs val in Kotlin: Mutable and Read-Only References Explained
Learn the difference between var and val in Kotlin, why both exist, and why a val object can still have mutable properties.
Page 2 of 2 - 32 questions