Properties, lazy & lateinit
KOTLIN › Language Idioms
Kotlin property mechanics: val/var/const, lazy vs lateinit, backing fields, custom accessors.
Properties are foundational Kotlin and a frequent warm-up that quickly exposes depth. Interviewers test whether you can pick lazy vs lateinit correctly, explain compile-time inlining of const val, and reason about backing fields and custom accessors. Strong answers cite concrete rules (no primitives in lateinit, lazy is val-only, thread-safety modes) rather than vague intuition.
What this covers
- When const val applies and how its value is inlined at compile time
- lazy (val, cached first-access init, thread-safety modes) vs lateinit (var, mutable, no primitives)
- Checking lateinit state with isInitialized and the exception thrown on early access
- When a backing field is generated and what the field keyword means
- Writing custom getters/setters and using the backing-property (_underscore) pattern
- val vs var semantics and where each can be initialized
Study this topic
- Properties, lazy & lateinit explained: the guided lesson
- 14 practice quiz questions
- 9 revision flashcards
- Properties, lazy & lateinit interview questions and answers