PrepPilotPractise free

Android & Kotlin interview questions

Kotlin, Jetpack Compose, lifecycle, coroutines, architecture

17 questions · Compose · updated November 2026

Practise these as flashcards. One or two lines each; the ones you miss come back first.

Start free

Core questions

What is Kotlin null safety and how does it help?

Kotlin null safety means that the type system differentiates between nullable and non-nullable types. This helps catch potential null pointer exceptions at compile time, making apps more robust and reducing runtime crashes.

How do you define a data class in Kotlin and what are its benefits?

A data class in Kotlin is declared with the data keyword and is used for classes that primarily hold data. It automatically generates useful methods like equals, hashCode, toString, and copy, making code more concise and readable.

What is an extension function in Kotlin? Give an example.

An extension function lets you add new functions to existing classes without modifying their source code. For example, fun String.isEmail() = contains("@") adds an isEmail method to the String class.

What is the purpose of the onSaveInstanceState method in an Activity?

onSaveInstanceState is used to save UI state before an Activity is destroyed, such as during a configuration change. The saved data can be restored in onCreate or onRestoreInstanceState to provide a seamless user experience.

Intermediate questions

How does Jetpack Compose handle UI state and recomposition?

Jetpack Compose uses state holders like remember and mutableStateOf to manage UI state. When the state changes, Compose automatically triggers recomposition, updating only the affected UI elements efficiently.

Explain the difference between viewModelScope and lifecycleScope.

viewModelScope is tied to the ViewModel's lifecycle and is used for launching coroutines that should survive configuration changes. lifecycleScope is tied to the lifecycle of an Activity or Fragment, and is suitable for UI-related coroutines that should be canceled when the lifecycle ends.

What is a Flow in Kotlin and how is it different from LiveData?

A Flow is a cold, asynchronous data stream that supports operators like map, filter, and can be collected in coroutines. Unlike LiveData, Flow is not tied to the Android lifecycle and is more flexible for complex data transformations and background operations.

How does Hilt help with dependency injection in Android?

Hilt simplifies dependency injection by automatically providing dependencies to Android components using annotations. It reduces boilerplate code, manages component lifecycles, and integrates well with ViewModels, Activities, and Fragments.

How do you persist data locally using Room?

Room provides an abstraction over SQLite, allowing you to define entities and DAOs for type-safe database access. You annotate data classes with @Entity and define queries in DAO interfaces, and Room generates the necessary code for CRUD operations.

What is WorkManager and when would you use it?

WorkManager is an API for scheduling deferrable, guaranteed background work that should run even if the app is killed or the device restarts. It's ideal for tasks like syncing data or uploading logs that must eventually complete.

How do you avoid blocking the main thread in Android?

I use coroutines or background threads to offload heavy operations like network or database access. For example, I launch coroutines with Dispatchers.IO for I/O tasks to keep the UI responsive and avoid ANRs.

How do you test ViewModel logic that uses coroutines and Flow?

I use runBlockingTest or TestCoroutineDispatcher from kotlinx-coroutines-test to control coroutine execution in tests. For Flow, I collect emissions in tests and assert expected values, and I use dependency injection to provide mock repositories.

Senior questions

Describe how you would architect a feature using MVVM, ViewModel, Repository, and Hilt.

See the answer in the app, free

How do you handle configuration changes in a Compose-based app?

See the answer in the app, free

What strategies do you use to prevent and diagnose ANRs in production?

See the answer in the app, free

How would you debug a Room database migration failure in production?

See the answer in the app, free

How do you minimize unnecessary recompositions in Jetpack Compose?

See the answer in the app, free

More Mobile topics