你的Android面试备忘录 - Android面试问题
Android Interview Questions and Answers - Your Cheat Sheet For Android Interview
Hi, I am Amit Shekhar, Co-Founder @ Outcome School • IIT 2010-14 • I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.
You can connect with me on:
Topics you should know in Kotlin Coroutines for Android Interview:
Learn the above-mentioned from the following links:
Topics you should know in Kotlin Flow API for Android Interview:
Learn the above-mentioned from the following links:
Android Interview Questions and Answers:
15 Kotlin Interview Questions and Answers: Check the PDF
What is the advantage of using const in Kotlin? - Video and Blog
When to use lateinit keyword used in Kotlin? - Learn from here
What are companion objects
in Kotlin? - Learn from here
Extension functions - Learn from here
What is a data class in Kotlin? - Learn from here
Remove duplicates from an array in Kotlin - Learn from here
What is a JvmOverloads Annotation in Kotlin? - Video and Blog
noinline in Kotlin - Learn from here
crossinline in Kotlin - Learn from here
scope functions in Kotlin - Learn from here
What is a reified keyword in Kotlin? - Learn from here
lateinit vs lazy in Kotlin - Learn from here
Advantage of using const in Kotlin - Learn from here
What are higher-order functions in Kotlin? - Learn from here: Higher-Order Functions and Lambdas in Kotlin
Write a function(Higher-Order Function) that returns a function. - Check solution here
What are Lambdas in Kotlin - Learn from here: Higher-Order Functions and Lambdas in Kotlin
AssociateBy - List to Map in Kotlin - Learn from here
Open keyword in Kotlin - Learn from here
Companion object in Kotlin - Learn from here
internal visibility modifier in Kotlin - Learn from here
partition - filtering function in Kotlin - Learn from here
Infix notation in Kotlin - Learn from here
How does the Kotlin Multiplatform work? - Learn from here
Suspending vs Blocking in Kotlin Coroutines - Learn from here
What is runBlocking in Coroutines? - Learn from here
What is the meaning of structured concurrency in Kotlin Coroutines? - Learn from here
String vs StringBuffer vs StringBuilder - Learn from here
What is the difference between val
and var
? - Learn from here
How to check if a lateinit
variable has been initialized? - Learn from here
How to do lazy initialization of variables in Kotlin? - Learn from here
What are the visibility modifiers in Kotlin? - Learn from here
What is the equivalent of Java static methods in Kotlin? - Learn from here
How to create a Singleton class in Kotlin? - Learn from here
What is the difference between open
and public
in Kotlin? - Learn from here
apply
scope function and its use cases - Learn from here
let
scope function and its use cases - Learn from here
Explain the use-case of let
, run
, with
, also
, apply
in Kotlin. - Learn from here and here
How to choose between apply
and with
? - Learn from here and here
Difference between List and Array types in Kotlin - Learn from here
What are Labels
in Kotlin? - Learn from here
What are Coroutines in Kotlin? - Learn from here
What is Coroutine Scope? - Learn from here
Scopes in Kotlin Coroutines Used in Android - Learn from here
What is Coroutine Context? - Learn from here
Launch vs Async in Kotlin Coroutines - Learn from here
Thread.sleep() vs delay() in Kotlin - Learn from here
Explain inline classes in Kotlin - Learn from here
When to use Kotlin sealed classes? - Learn from here
Tell about the Collections in Kotlin - Learn from here
What does ?: do in Kotlin? (Elvis Operator) - Learn from here
timeouts in Kotlin Coroutines - Learn from here
How do you combine multiple coroutine results? - Learn from here
What is a Job in Coroutines? - Learn from here
How to Implement Debounce Using Coroutines? - Learn from here
Kotlin code snippet demonstrating how to run two coroutines in series and parallel - Learn from here
yield in Kotlin Coroutines - Learn from here
Delegates in Kotlin - Learn from here
Android Interview Questions and Answers:
Why does an Android App lag? - Learn from here
What is Context
? How is it used? - Context In Android Application
Tell all the Android application components. - Learn from here
What is the project structure of an Android Application? - Learn from here
What is AndroidManifest.xml
? - Learn from here
What is the Application
class? -Learn from here
Why is it recommended to use only the default constructor to create a Fragment
? - Learn from video and blog
What is Activity
and its lifecycle? - Learn from here
What is the difference between onCreate() and onStart() - Learn from here
When only onDestroy is called for an activity without onPause() and onStop()? - Learn from here
Why do we need to call setContentView() in onCreate() of Activity class? - Learn from here
What is onSaveInstanceState() and onRestoreInstanceState() in activity? - Learn from here
What is Fragment
and its lifecycle? - Learn from here
What are “launchMode”? - Learn from here and singleTask launchMode in Android
What is the difference between a Fragment
and an Activity
? Explain the relationship between the two. - Learn from here
When should you use a Fragment rather than an Activity?
What is the difference between FragmentPagerAdapter vs FragmentStatePagerAdapter?
What is the difference between adding/replacing fragment in backstack? - Learn from here
How would you communicate between two Fragments?
What is retained Fragment
? - Learn from here
What is the purpose of addToBackStack()
while commiting fragment transaction?
Optimizing layouts in Android - Learn from here
What is View
in Android?
Difference between View.GONE
and View.INVISIBLE
? - Learn from here
Can you a create custom view? How?
What are ViewGroups and how they are different from the Views?
What is a Canvas? - Learn from here
What is a SurfaceView
? - Learn from here
Relative Layout vs Linear Layout.
Tell about Constraint Layout optimization - Learn from here
Do you know what is the view tree? How can you optimize its depth? - Learn from here
What is the difference between ListView
and RecyclerView
? - Learn from here
How does the RecyclerView work? - Learn from here
RecyclerView Optimization - Scrolling Performance Improvement - Learn from here
Optimizing Nested RecyclerView - Learn from here
How does RecyclerView improve performance over ListView?
What are the components of a RecyclerView?
Explain the role of RecyclerView.Adapter and RecyclerView.ViewHolder - Learn from here
What is a LayoutManager in RecyclerView?
How do you handle multiple view types in a single RecyclerView?
What is DiffUtil and how does it improve RecyclerView performance? - Learn from here
What is the purpose of RecyclerView.setHasFixedSize(true)? - Learn from here
How do you update a specific item in RecyclerView?
What is SnapHelper
? - Learn from here: SnapHelper
What is Dialog
in Android? - Learn from here
What is Toast
in Android? - Learn from here
What the difference between Dialog
and Dialog Fragment
? - Learn from here
What is Intent
? - Learn from here
What is an Implicit Intent
? - Learn from here
What is an Explicit Intent
? - Learn from here
What is a BroadcastReceiver
? - Learn from here
What is a Sticky Intent
?
Describe how broadcasts and intents work to be able to pass messages around your app? - Learn from here
What is a PendingIntent
?
What are the different types of Broadcasts? - Learn from here
Explain Android Service Lifecycle - Learn from here
What is Service? - Learn from here
On which thread does a Service run in Android? - Learn from here
Service vs IntentService - Learn from here
What is a Foreground Service? - Learn from here
What is a JobScheduler
? - Learn from here
How can two distinct Android apps interact? - Learn from here
Is it possible to run an Android app in multiple processes? How? - Learn from here
What is AIDL? Enumerate the steps in creating a bounded service through AIDL. - Learn from here
What can you use for background processing in Android? - Learn from here
What is a ContentProvider
and what is it typically used for? - Learn from here
How to run parallel tasks and get a callback when all are complete? - Long-running tasks in parallel with Kotlin Flow
What is ANR? How can the ANR be prevented? - Learn from here
ThreadPool Advantages - Learn from here
What is an AsyncTask
(Deprecated in API level 30) ?
What are the problems in AsyncTask?
Daemon Threads vs. User Threads - Learn from here
Explain Looper
, Handler
, and HandlerThread
.
Garbage Collection - Learn from here
Android Memory Leak
Can you explain the difference between a Runnable and a Thread in Android? - Learn from here
How do you handle bitmaps in Android as it takes too much memory? - Learn from here and here
Tell about the Bitmap
pool. - Learn from here
Jetpack DataStore Preferences - Learn from here
Persisting Data in an Android App - Learn from here
What is ORM? How does it work?
How would you preserve the Activity
state during a screen rotation? - Learn from here
What are different ways to store data in your Android app?
Explain Scoped Storage in Android.
How to encrypt data in Android?
What is commit() and apply() in SharedPreferences?
What is a Spannable
?
What is a SpannableString
?
What are the best practices for using text in Android?
How to implement Dark mode in any application?
What is the onTrimMemory()
method? - Learn from here
How to identify and fix OutOfMemory issues?
How do you find memory leaks in Android applications?
How to reduce battery usage in an android application?
What is Doze? What about App Standby? - Learn from here
What is overdraw
? - Learn from here
What is the NDK and why is it useful? - Learn from here: Android NDK and RenderScript
What is renderscript? - Learn from here: Android NDK and RenderScript
What is Android Runtime? - Android Runtime
Dalvik, ART, JIT, and AOT in Android - Dalvik, ART, JIT, and AOT
What are the differences between Dalvik and ART? - Difference between Dalvik and ART
What is DEX? - Learn from here
What is Multidex in Android? - Learn from here
Can you manually call the Garbage collector? - Is it possible to force Garbage Collection in Android?
What is Android Jetpack and why to use this?
What is a ViewModel and how is it useful? Learn: What is a ViewModel and how is it useful?
SharedViewModel in Android Learn: SharedViewModel in Android
What are Android Architecture Components?
What is LiveData in Android?
How is LiveData different from ObservableField?
What is the difference between setValue and postValue in LiveData? Learn: setValue() vs postValue() in LiveData
How do you share ViewModel between Fragments in Android? Learn: SharedViewModel in Android
Explain WorkManager and its use cases.
How does ViewModel work internally?
What is the difference between Serializable and Parcelable? Which is the best approach in Android? - Learn from here
Why Bundle class is used for data passing and why cannot we use simple Map data structure? - Learn from here
How do you troubleshoot a crashing application? - Learn from here
Explain the Android push notification system? Learn from here: How does the Android push notification system work?
What is AAPT? - Learn from here
FlatBuffers vs JSON.
HashMap
, ArrayMap
and SparseArray
- Learn from here
What are Annotations? - Learn from here
How to create custom Annotation? - Learn from here
What is the Android Support Library? Why was it introduced? - Learn from here
What is Android Data Binding?
Android Interview Questions and Answers:
Explain OkHttp Interceptor - Learn from here
OkHttp - HTTP Caching - Learn from here
How to enable logging in OkHttp? - Learn from here
Why do we use the Dependency Injection Framework like Dagger in Android? - Learn from here
How does the Dagger work?
How will you choose between Dagger 2 and Dagger-Hilt?
What is a Component in Dagger?
What is Module in Dagger?
How does the custom scope work in Dagger?
When to call dispose and clear on CompositeDisposable in RxJava? - Learn from here
What is Multipart Request in Networking?
What is Flow in Kotlin? - Learn from here
App Startup Library - Learn from here
Tell me something about RxJava.
How will you handle error in RxJava?
FlatMap Vs Map Operator - Learn from here
When to use Create
operator and when to use fromCallable
operator of RxJava? - Learn from here: RxJava Create and fromCallable Operator
When to use defer
operator of RxJava? - Learn from here: RxJava Defer Operator
How are Timer, Delay, and Interval operators used in RxJava? - Learn from here
How to make two network calls in parallel using RxJava? - RxJava Zip Operator
Tell the difference between Concat and Merge. - Learn from here and here
Explain Subject in RxJava? - Learn from here
What are the types of Observables in RxJava? - Learn from here: Types Of Observables In RxJava
How to implement search feature using RxJava in your application? - Learn from here: Instant Search Using RxJava Operators
Pagination In RecyclerView Using RxJava Operators - Learn from here
How The Android Image Loading Library Glide and Fresco Works? - Learn from here, here and here
Difference between Schedulers.io() and Schedulers.computation() in RxJava.
Android Interview Questions and Answers:
Describe the architecture of your last app.
Describe MVVM. - MVVM Architecture
MVC vs MVP vs MVVM architecture.
Clean Architecture - Learn from here
Software Architecture vs Software Design - Learn from here
Benefits of Multi-Module Architecture - Learn from here
Android Interview Questions and Answers
Android Interview Questions and Answers:
Refer to this blog: Android System Design Interviews
Design an Image Loading Library - Learn from here, here and here
Design File Downloader Library - Learn from here
Design WhatsApp
Design Instagram Stories
Design Networking Library
Design Facebook Near-By Friends App
Design Caching Library.
Design problems based on location-based app
How to build an offline-first app? Explain the architecture
Design LRU Cache
Design Analytics Library
HTTP Request vs HTTP Long-Polling vs WebSocket vs Server-Sent Events - Learn from blog and Video - HTTP Request vs HTTP Long-Polling vs WebSocket vs Server-Sent Events
How do Voice And Video Call Work? - Learn from here
Design Uber App - Learn from here
Database Normalization vs Denormalization - Database Normalization vs Denormalization
Hash vs Encrypt vs Encode - Learn from here
Webhook vs Polling - Learn from here
Options for real-time updates in an Android App - Learn from here
Options for Network Optimization in a Mobile App - Options for Network Optimization in a Mobile App
Firebase Remote Config in Android - Firebase Remote Config in Android
Accurate time in Android - Learn from here
Query Optimization in SQLite for Better Performance - Learn from here
WebSocket vs Socket.IO - Learn from here
Symmetric vs Asymmetric Encryption - Learn from here
SMS Retriever API in Android - Learn from here
Android Interview Questions and Answers:
Unit Testing ViewModel with Kotlin Coroutines and LiveData - Learn from here
Unit Testing ViewModel with Kotlin Flow and StateFlow - Learn from here
What is Espresso? - Learn from here
What is Robolectric? - Learn from here
What are the disadvantages of using Robolectric? - Learn from here
What is UI-Automator? - Learn from here
Explain the unit test. - Learn from here
Explain instrumented test. - Learn from here
Why Mockito is used? - Learn from here
Describe code coverage. - Learn from here
Android Interview Questions and Answers:
CI/CD Pipeline for Android - Learn from here
What is ADB? - Learn from here
What is the StrictMode? - Learn from here: StrictMode
What is Lint? What is it used for?
Android App Release Checklist For The Production Launch - Learn from here: Android App Release Checklist For The Production Launch
Git.
Firebase. - Learn from here
How to measure method execution time in Android?
Can you access your database of SQLite Database for debugging? - Learn from here
What are things that we need to take care while using Proguard?
How to use Android Studio Memory Profiler?
What is Kotlin DSL for Gradle? - Learn from here
implementation vs api in Gradle - Learn from here
What is Gradle?
Gradle related files in Android Project - Learn from here
How do you create a custom task in Gradle? - Learn from here
annotationProcessor, kapt, ksp in Gradle - Learn from here
Build Variants in Android - Learn from here
APK Size Reduction.
How can you speed up the Gradle build?
About gradle build system.
About multiple apk for Android Apps.
What is ProGuard used for? - Learn from here
What is proguard-rules.pro file used for? - Learn from here
What is obfuscation? What is it used for? What about minification?
How to change some parameters in an app without app update? - Firebase Remote Config in Android
What is Write-Ahead Logging (WAL) and why it is used internally in databases? - Learn from here
Android Interview Questions and Answers:
Explain OOP Concepts.
Differences between abstract classes and interfaces?
Difference between method overloading and overriding.
What are the access modifiers you know? What does each one do?
private
variables, methods, constructors or inner classes are only visible to its’ containing class and its’ methods. This modifier is most commonly used, for example, to allow variable access only through getters and setters or to hide underlying implementation of classes that should not be used by user and therefore maintain encapsulation. Singleton constructor is also marked private
to avoid unwanted instantiation from outside.Default
(no keyword is used) this modifier can be applied to classes, variables, constructors and methods and allows access from classes and methods inside the same package.protected
can be used on variables, methods and constructors therefore allowing access only to subclasses and classes that are inside the same package as protected members’ class.public
modifier is widely-used on classes, variables, constructors and methods to grant access from any class and method anywhere. It should not be used everywhere as it implies that data marked with public
is not sensitive and can not be used to harm the program.Can an Interface implement another Interface?
extends
, rather than implements
keyword. And while you can not remove methods from parent interface, you can add new ones freely to your sub-interface.What is Polymorphism? What about Inheritance?
Arrays Vs ArrayLists - Learn from here
HashSet Vs TreeSet - Learn from here
HashMap Vs Set - Learn from here
Explain Generics in Java?
How is String
class implemented? Why was it made immutable?
There is no primitive variant of String
class in Java language - all strings are just wrappers around underlying array of characters, which is declared final
. This means that, once a String
object is instantiated, it cannot be changed through normal tools of the language (Reflection still can mess things up horribly, because in Java no object is truly immutable). This is why String
variables in classes are the first candidates to be used, when you want to override hashCode()
and equals()
of your class - you can be sure, that all their required contracts will be satisfied.
Note: The String class is immutable, so that once it is created a String object cannot be changed. The String class has a number of methods, some of which will be discussed below, that appear to modify strings. Since strings are immutable, what these methods really do is create and return a new string that contains the result of the operation. (Official Java Documentation)
This class is also unique in a sense, that, when you create an instance like this:
String helloWorld = "Hello, World!";
"Hello, World!"
is called a literal and compiler creates a String
object with its’ value. So
String capital = "Hello, World!".toUpperCase();
is a valid statement, that, firstly, will create an object with literal value “Hello, World!” and then will create and return another object with value “HELLO, WORLD!”
String
was made immutable to prevent malicious manipulation of data, when, for example, user login or other sensitive data is being send to a server.What does it means to say that a String
is immutable?
String
object’s char[]
(its’ containing value) is declared final
and, therefore, it can not be changed during runtime.Can you list 8 primitive types in java?
byte
short
int
long
float
double
char
boolean
What is the difference between an Integer and int?
int
is a primitive data type (with boolean
, byte
, char
, short
, long
, float
and double
), while Integer
(with Boolean
, Byte
, Character
, Short
,Long
, Float
and Double
) is a wrapper class that encapsulates primitive data type, while providing useful methods to perform different tasks with it.Do objects get passed by reference or value in Java? Elaborate on that.
What does the keyword synchronized
mean?
What is a ThreadPoolExecutor
? - ThreadPoolExecutor in Android
What is volatile
modifier?
Object Level Lock vs Class Level Lock in Java - Learn from here
Concurrency vs Parallelism - Learn from here
The classes in the atomic package expose a common set of methods: get
, set,
, lazyset
, compareAndSet
, and weakCompareAndSet
. Please describe them.
How does the try{}
, catch{}
, finally
works?
What is the difference between a Checked Exception
and an Un-Checked Exception
?
Shallow vs. Deep Copy in Java - Learn from here
Explain Serialization and Deserialization - Learn from here
What is serialization? How do you implement it?
What is transient
modifier?
What are anonymous classes?
What is the difference between using ==
and .equals
on an object?
What is the hashCode()
and equals()
used for?
When would you make an object value final
?
What are these final
, finally
and finalize
keywords?
What is the difference between “throw” and “throws” keyword in Java?
throws
is just used to indicated which exception is to be thrown. But the throw
keyword is used to throw some exception from any static block or any method.What does the static
word mean in Java?
static
variable it means that this variable (its’ value or the object it references) spans across all instances of enclosing class (changing it in one instance affects all others), while in case of static
methods it means that these methods can be invoked without an instance of their enclosing class. It is useful, for example, when you create util classes that need not be instantiated every time you want to use them.Can a static
method be overridden in Java?
When is a static
block run?
Explain Reflection in Java - Learn from here
What is Dependency Injection?
Difference between StringBuffer
and StringBuilder
? - Learn from here
What is the difference between fail-fast and fail-safe iterators in Java?
Monitor and Synchronization
Topics you should know in Jetpack Compose for Android Interview:
Learn the above-mentioned from the following links:
Questions
Jetpack Compose vs Android View System
Explain the concept of declarative UI in Jetpack Compose.
Declarative UI vs Imperative UI
What are Composable functions?
What is Recomposition?
What is State in Compose?
How does state management work in Jetpack Compose?
Stateful composable vs Stateless composable
What are the side effects?
Difference between LaunchedEffect and DisposableEffect.
What is rememberCoroutineScope and its use cases?
How to observe Flows, and LiveData states in Compose UI?
How can we handle asynchronous operations in Jetpack Compose?
How can we convert a non-compose state into a Compose state?
Explain derivedStateOf.
Explain rememberUpdatedState.
Difference between remember and rememberSaveable. - Learn from here
Explain the Lifecycle of a Composable in Jetpack Compose.
How do you handle lifecycle events in Compose functions?
What are the best practices for performance optimization in Jetpack Compose?
Can we use both Jetpack Compose and Android View in a Single App?
What is State Hoisting?
Explain CompositionLocal
Explain Jetpack Compose Phases.
What is the role of the Modifier in Jetpack Compose?
What are Semantics?
How can you handle user input and events in Jetpack Compose?
How do you handle navigation in Jetpack Compose?
How do you handle orientation changes in Jetpack Compose?
Explain the concept of unidirectional data flow in Jetpack Compose.
How to create Custom Layouts in Compose?
Android Interview Questions and Answers:
Describe SQLite.
Have you used Room?
Can we identify the users who have uninstalled our application?
Android Development Best Practices. - Learn from here: Android Development Best Practices
React Native vs Flutter - Learn from here: React Native vs Flutter
What are the metrics that you should measure continuously while android application development? - Learn from here: Android App Performance Metrics
How to avoid API keys from check-in into VCS?
How does the Kotlin Multiplatform work? - Blog
How to use Memory Heap Dumps data?
How to implement Dark Theme in your app?
How to secure the API keys used in an Android App?
What is Cleartext traffic? Learn from here: What is Cleartext traffic?
Tell something about memory usage in Android.
Explain Annotation processing.
How does the Android Push Notification system work? Learn from here: How does the Android Push Notification system work?
Android Push Notification Flow using FCM. Learn from here: Android Push Notification Flow using FCM
How to show local Notification at an exact time?
You can connect with me on:
Copyright (C) 2024 Amit Shekhar
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.