All questions
Showing of 41Explain var vs val in Kotlin
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
- val: Immutable reference (read-only), similar to
finalin Java. The reference cannot be reassigned, but the object itself may be mutable - var: Mutable reference, can be reassigned
val name = "John" // Cannot be reassigned
var age = 25 // Can be reassigned
age = 26 // Valid
val list = mutableListOf(1, 2, 3)
list.add(4) // Valid - object is mutable
// list = mutableListOf() // Error - reference is immutable
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is type inference in Kotlin?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Type inference allows the compiler to automatically determine the type of a variable without explicit declaration. This reduces verbosity while maintaining type safety.
val name = "John" // Inferred as String
val age = 25 // Inferred as Int
val price = 99.99 // Inferred as Double
val users = listOf<User>() // Explicit type needed for empty collections
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are data classes in Kotlin and their benefits?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Data classes are classes specifically designed to hold data. The compiler automatically generates equals(), hashCode(), toString(), copy(), and destructuring declarations.
data class Person(val name: String, val age: Int)
val person1 = Person("Alice", 30)
val person2 = person1.copy(age = 31) // Copy with modification
val (name, age) = person1 // Destructuring
println(person1) // Automatically generated toString()
Requirements for data classes:
- Primary constructor must have at least one parameter
- All parameters must be marked as
valorvar - Cannot be abstract, open, sealed, or inner
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are lambda expressions and their syntax?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Lambda expressions are anonymous functions that can be passed as arguments or stored in variables.
// Basic syntax: { parameters -> body }
val multiply = { a: Int, b: Int -> a * b }
// Single parameter - 'it' keyword
listOf(1, 2, 3).map { it * 2 }
// Trailing lambda syntax
listOf(1, 2, 3).filter { number ->
number > 1
}
// Multiple parameters
mapOf("a" to 1, "b" to 2).forEach { (key, value) ->
println("$key: $value")
}
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain Kotlin's null safety features
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Kotlin's type system distinguishes between nullable and non-nullable types, eliminating null pointer exceptions at compile time.
var name: String = "John" // Non-nullable
// name = null // Compilation error
var nullableName: String? = "John" // Nullable
nullableName = null // OK
// Safe call operator
val length = nullableName?.length
// Elvis operator
val displayName = nullableName ?: "Unknown"
// Not-null assertion (use carefully)
val definiteLength = nullableName!!.length
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between safe call (?.) and not-null assertion (!!)?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Safe Call (?.): Returns null if the object is null, preventing null pointer exceptions.
Not-null Assertion (!!): Converts nullable type to non-nullable, throws exception if null.
val name: String? = getName()
// Safe call - returns null if name is null
val upperCase = name?.uppercase()
// Not-null assertion - throws KotlinNullPointerException if name is null
val definiteUpperCase = name!!.uppercase()
// Chaining safe calls
val result = person?.address?.street?.length
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the difference between mutable and immutable collections
Explain the Android Activity lifecycle
What are Intents and how are they used?
Explain the difference between Activities and Fragments
Explain Kotlin's when expression
Explain primary and secondary constructors in Kotlin
What are sealed classes and when would you use them?
Explain object declarations and object expressions
What are higher-order functions in Kotlin?
Explain extension functions and their benefits
How do you handle exceptions in Kotlin?
What are useful collection operations in Kotlin?
What are Kotlin coroutines and why are they important?
Explain suspend functions in Kotlin
How do you handle errors in coroutines?
What is the Fragment lifecycle?
What is ViewModel and why is it important?
Explain LiveData and its benefits
What is the Repository pattern in Android?
Explain dependency injection and why it's useful
How do you implement RecyclerView with different item types?
What is data binding and how does it work?
How do you handle different screen sizes and orientations?
How do you optimize RecyclerView performance?
How do you write unit tests for Kotlin Android code?
What are instrumented tests and how do you write them?
How do you handle deep linking in Android?
What are some Kotlin best practices for Android development?
What are coroutine scopes and contexts?
How do you prevent memory leaks in Android?
What are best practices for background processing?
What are Kotlin Multiplatform projects?
How do you implement custom views in Android?
Explain Android app architecture patterns (MVVM, MVP, MVI)
How do you implement offline-first architecture?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Kotlin cheatsheet
- Kotlin Basics01
- Functions02
- Classes and Objects03
- Collections04
- Coroutines05
- Android Specific06
- Delegation07
- Generics08
- Scope Functions09
- Common Interview Patterns10
- Best Practices & Tips11
- Performance & Best Practices12
- + 2 more inside
- + 8 more inside
35 of 41 Kotlin answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.