Interview Prep · Android Development
Top 10 Android Development Interview Questions & Answers
Quick summary — top 10 Android interview questions
Android development interviews test your understanding of the platform, architecture, and best practices. This guide covers the top 10 questions you're likely to face, with detailed answers, code examples, and explanations.
In this guide you will learn:
- Core Concepts — Activity lifecycle, Fragments, Intents.
- Kotlin & Architecture — Kotlin features, MVVM, Coroutines.
- Advanced Topics — RecyclerView, DI, Testing, Performance.
- Interview Tips — how to approach and solve problems.
Q1Explain the Android Activity Lifecycle
Question: Explain the Android Activity lifecycle and its callback methods. What happens when an activity is rotated?
Activity Lifecycle — Callback methods:
1. onCreate() — Called when activity is created. Initialize UI.
2. onStart() — Activity becomes visible to the user.
3. onResume() — Activity is in the foreground and interactive.
4. onPause() — Activity is partially obscured (e.g., dialog).
5. onStop() — Activity is no longer visible (e.g., new activity).
6. onDestroy() — Activity is destroyed (finish() or system).
7. onRestart() — Activity restarts after being stopped.
When screen rotates:
1. onPause() → onStop() → onDestroy() → onCreate() → onStart() → onResume()
2. The activity is destroyed and recreated.
Important: Use onSaveInstanceState() to save state before rotation.
Q2What are Fragments? Why use them?
Question: What are Fragments? How do they differ from Activities? Why would you use a Fragment?
Fragment — A reusable UI component inside an Activity.
Key differences from Activity:
- Fragment has its own lifecycle (linked to parent Activity)
- Fragment is managed by the FragmentManager
- Multiple Fragments can be in one Activity
- Fragments can be reused across Activities
Why use Fragments?
1. Modularity — Break UI into reusable components
2. Flexibility — Handle different screen sizes (phone/tablet)
3. Navigation — Implement complex navigation patterns
4. ViewPager — Swipeable pages
Lifecycle: onAttach() → onCreate() → onCreateView() → onViewCreated() → onStart() → onResume() → ...
Q3What is an Intent? Types of Intents
Question: What is an Intent in Android? Explain the different types of Intents and when to use them.
Intent — A messaging object used to request an action.
Types of Intents:
1. Implicit Intent:
- Doesn't specify the component name.
- System finds the appropriate app to handle the action.
- Example: ACTION_VIEW, ACTION_SEND
2. Explicit Intent:
- Specifies the exact component (Activity, Service) by name.
- Used to start a specific component within your app.
Common uses:
- Start an Activity: startActivity(intent)
- Start a Service: startService(intent)
- Broadcast a message: sendBroadcast(intent)
Example:
// Explicit
val intent = Intent(this, SecondActivity::class.java)
startActivity(intent)
// Implicit
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com"))
startActivity(intent)
Q4Key Features of Kotlin
Question: What are some key features of Kotlin that make it better for Android development compared to Java?
Kotlin — Key features:
1. Null Safety:
var name: String? = null // Nullable type
var name: String = "Ankit" // Non-nullable
2. Data Classes:
data class User(val id: Int, val name: String)
3. Extension Functions:
fun String.reverse(): String = this.reversed()
4. Coroutines — Asynchronous programming with async/await
5. Lambda Expressions and Higher-Order Functions
6. Type Inference — Less boilerplate
7. Smart Casts — Type checking and casting
8. Companion Objects — Similar to static members
Why Kotlin?
- Less code = fewer bugs
- Interoperable with Java
- Official support from Google
- Modern language features
Q5What is MVVM Architecture?
Question: Explain MVVM architecture in Android. What are the components and how do they interact?
MVVM (Model-View-ViewModel) — Architecture pattern
Components:
1. Model: Data layer (database, network, repository)
2. View: UI components (Activity, Fragment)
3. ViewModel: Holds UI state and business logic
Flow:
View observes LiveData in ViewModel
ViewModel calls Repository
Repository fetches data from Network/Database
LiveData — Observable data holder
ViewModel — Survives configuration changes
Data Binding — Binds UI components to ViewModel
Benefits:
- Separation of concerns
- Testability
- Configuration change resilience
- Clean code architecture
Q6What are Coroutines?
Question: What are Kotlin Coroutines? How do they help with asynchronous programming in Android?
Coroutines — Lightweight threads for asynchronous programming.
Key Concepts:
1. suspend — Function that can be paused and resumed
2. launch — Starts a new coroutine (fire and forget)
3. async — Returns a Deferred result (use with await())
4. withContext — Switch dispatchers (e.g., IO to Main)
Dispatchers:
- Dispatchers.Main — UI thread
- Dispatchers.IO — Network, database operations
- Dispatchers.Default — CPU-intensive work
Example:
viewModelScope.launch {
val result = withContext(Dispatchers.IO) {
fetchDataFromNetwork() // suspend function
}
updateUI(result) // On Main thread
}
Benefits:
- Non-blocking operations
- Cancellation support
- Structured concurrency
- Less boilerplate than RxJava
Q7How does RecyclerView work?
Question: How does RecyclerView work? What are its key components and why is it more efficient than ListView?
RecyclerView — Efficient list display component.
Key Components:
1. Adapter — Connects data to the view
2. ViewHolder — Holds references to views (cached)
3. LayoutManager — Positions items (Linear, Grid, Staggered)
4. ItemAnimator — Animations for item changes
Why more efficient than ListView?
- ViewHolder pattern (cached views)
- Only renders visible items
- Customizable layouts
- Built-in animations
Implementation:
class MyAdapter(private val data: List<String>) :
RecyclerView.Adapter<MyAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_layout, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bind(data[position])
}
override fun getItemCount(): Int = data.size
}
Q8What is Dependency Injection?
Question: What is Dependency Injection and why is it important in Android development?
Dependency Injection (DI) — A pattern where objects receive their
dependencies from outside rather than creating them internally.
Why DI?
- Loose coupling
- Testability (easier to mock)
- Cleaner code
- Single responsibility
Popular DI frameworks for Android:
1. Dagger — Compile-time DI (complex but powerful)
2. Hilt — Opinionated wrapper around Dagger (recommended)
3. Koin — Lightweight, Kotlin-friendly (runtime DI)
Example (without DI):
class UserRepository {
private val api = ApiService() // Hard dependency
}
Example (with DI):
class UserRepository(private val api: ApiService) { ... }
// Hilt injection:
@HiltAndroidApp
class MyApplication : Application()
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
@Inject lateinit var userRepository: UserRepository
}
Q9How do you test Android apps?
Question: What are the different types of tests in Android? How would you write a unit test and an UI test?
Types of Tests in Android:
1. Unit Tests — Test small units of code (no Android dependencies).
- Run on JVM (fast)
- Tools: JUnit, Mockito, Truth
2. Integration Tests — Test interactions between components.
- Run on JVM with Robolectric (or on device)
- Tools: Robolectric
3. UI Tests — Test the UI and user interactions.
- Run on real device or emulator
- Tools: Espresso, UI Automator
Unit Test Example:
@Test
fun testUserRepository() {
val mockApi = mock(ApiService::class.java)
val repo = UserRepository(mockApi)
`when`(mockApi.getUsers()).thenReturn(listOf(User(1, "Test")))
val result = repo.getUsers()
assertEquals(1, result.size)
}
UI Test Example (Espresso):
@Test
fun testLoginSuccess() {
onView(withId(R.id.username)).perform(typeText("admin"))
onView(withId(R.id.password)).perform(typeText("password"))
onView(withId(R.id.loginButton)).perform(click())
onView(withId(R.id.welcomeText)).check(matches(isDisplayed()))
}
Q10How do you optimize Android app performance?
Question: How would you optimize an Android app for performance? What tools and techniques would you use?
Performance Optimization — Key areas:
1. Memory:
- Use Android Studio Memory Profiler
- Avoid memory leaks (use WeakReferences, Lifecycle callbacks)
- Use ViewModel for configuration changes
- Optimize bitmaps (use Glide/Coil)
2. UI/Rendering:
- Use the Layout Inspector
- Reduce overdraw (remove unnecessary backgrounds)
- Use ConstraintLayout for complex layouts
- Use RecyclerView instead of ListView
3. Network:
- Use caching (OkHttp Cache)
- Compress data (Gzip)
- Use pagination for large data sets
4. Battery:
- Minimize wakelocks and alarms
- Use JobScheduler/WorkManager for background tasks
- Avoid frequent network calls
5. Tools:
- Android Studio Profilers (CPU, Memory, Network)
- LeakCanary for memory leaks
- StrictMode for performance violations
SECTION 11Interview Tips for Android Developers
Here are some key tips to ace your Android interview:
- Understand the lifecycle — Activity, Fragment, and Service lifecycles are fundamental. Know what happens in each callback.
- Know your architecture — Be prepared to discuss MVVM, MVI, or MVP and why you would choose one over another.
- Show your Kotlin knowledge — Know null safety, extension functions, coroutines, and data classes.
- Think about performance — Always consider memory, battery, and UI performance when discussing solutions.
- Be ready to code — Practice writing code on a whiteboard or in a text editor without auto-complete.
SECTION 12Test yourself — Android interview quiz
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 13Frequently asked questions
What is the most important topic for an Android interview?
The Activity lifecycle is the most important topic — almost every Android interview will include questions about it. Also know Kotlin, MVVM, and RecyclerView.
Do I need to know Java for Android interviews?
Most companies have transitioned to Kotlin, but some legacy projects may use Java. Knowing Java basics is helpful, but Kotlin fluency is more important.
What is the best way to prepare for an Android interview?
Build projects, practice coding problems, review the topics in this guide, and do mock interviews. Also contribute to open-source Android projects.
What are the most common Android interview questions?
Activity lifecycle, Fragments, Intents, Kotlin features, MVVM, Coroutines, RecyclerView, and dependency injection are the most common topics.
SECTION 07Related reads
Classroom & online · Noida
Master Android Development & Crack Interviews
Our Android Development Training Course covers all the topics in this guide — with hands-on coding, mock interviews, and placement support.
₹14,000 · full programme- Complete Android curriculum
- 5+ live projects
- Mock interviews
- Placement support

