Questions

Kotlin questions

Choose a question page, learn the concept, then test your understanding with a quiz.

Kotlin Class vs Object: Why Java Static Methods Convert to object

Learn the difference between Kotlin classes and objects, why Java static utility methods become objects, and when to use companion objects.

kotlinjavaandroid

Kotlin Companion Object Explained: Static Replacement, Meaning, and Best Practices

Learn what a Kotlin companion object is, why it replaces Java static members, and when to use it for factories, constants, and singletons.

kotlinkotlin-companion

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.

kotlinconstants

Kotlin Constructor References: Using ::ClassName for Factories

Learn how Kotlin constructor references use ::ClassName, how they compare with Java Class::new, and how to apply them in factories.

kotlinfunction-referenceconstructor-reference

Kotlin Data Class Default Constructor and Optional Parameters in Android

Learn how to create an empty-like constructor for a Kotlin data class using default parameter values in Android.

kotlinandroid

Kotlin Data Classes and Gson @SerializedName Annotations

Learn how to map JSON keys to Kotlin data class properties with Gson using @SerializedName and Kotlin’s @field: use-site target.

kotlinjavajsongson

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.

kotlinkotlin-null-safety

Kotlin EditText addTextChangedListener Lambda Guide

Learn how to use Kotlin lambdas with Android EditText addTextChangedListener, handle nullable text safely, and choose the right callback.

kotlinandroidtextviewanko

Kotlin Enum Reverse Lookup: Map Values Back to Enum Constants

Learn efficient Kotlin enum reverse lookup with companion objects, entries, associateBy, lazy maps, duplicate-key handling, and reusable patterns.

kotlinenums

Kotlin Equivalent of Java String[]: Arrays of Strings Explained

Learn the Kotlin equivalent of Java String[] and understand Array<String>, primitive arrays, syntax, examples, mistakes, and usage.

kotlinjava

Kotlin Generics: Difference Between `*` and `Any`

Learn the difference between `SomeGeneric<*>` and `SomeGeneric<Any>` in Kotlin generics, with examples of star projections, variance, and safe usage.

kotlingenerics

Kotlin Getters and Setters: Properties, Accessors, and Visibility

Learn how Kotlin getters and setters work, how property visibility affects accessors, and how to expose read-only values safely.

kotlingetter-setter

Kotlin Inheritance and Interface Implementation: Extend a Class and Implement an Interface

Learn how Kotlin classes extend one superclass and implement one or more interfaces, including syntax, overrides, and common pitfalls.

kotlinjava

Kotlin Interfaces and SAM Conversion: Why "Interface Does Not Have Constructors" Happens

Learn why Kotlin shows "Interface does not have constructors", how SAM conversion works, and how to instantiate interfaces correctly.

kotlinjava

Kotlin JUnit @Rule Visibility with ActivityTestRule in Android Tests

Learn why Kotlin JUnit @Rule fields fail visibility checks in ActivityTestRule tests and how to fix them with @JvmField.

kotlinandroidtestingandroid-espresso

Kotlin List Casting: Safely Converting List<*> to List<Waypoint> Without Unchecked Cast Warnings

Learn why Kotlin shows unchecked cast warnings for List<*> to List<Waypoint> and how to safely filter and validate typed lists.

kotlinlistgenericscasting

Kotlin List vs MutableList: Why add, remove, and put Are Missing

Learn why Kotlin List and Map do not have add, remove, or put, and how MutableList and MutableMap solve it safely.

kotlincollections

Kotlin Nullable Types: Idiomatic Ways to Handle, Convert, and Assert Non-Null Values

Learn the idiomatic Kotlin ways to handle nullable types, convert to non-null values, and use safe calls, Elvis, and !! correctly.

kotlinnullablenon-nullable

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.

kotlinproperties

Kotlin Public Getter Private Setter for var: How Accessors Work

Learn how to declare a Kotlin var with a public getter and private setter, with syntax, examples, mistakes, and real use cases.

kotlin

Page 6 of 9 - 162 questions