This is a short version of android interview questions. Initially prepared and maintained by Amit Shekhar who is having experience of taking interviews of many Android developers and cracking interviews of top companies.
- Core Android
- Android Libraries
- Android Architecture
- Android Unit Testing
- Android Tools And Technologies
- Kotlin
-
Tell all the Android application components. - Learn from here
-
What is the project structure of an Android Application? - Learn from here
-
What is
Context
? How is it used? - Learn from here -
What is
AndroidManifest.xml
? - Learn from here -
What is
Application
class?- The Application class in Android is the base class within an Android app that contains all other components such as activities and services. The Application class, or any subclass of the Application class, is instantiated before any other class when the process for your application/package is created.
-
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 onSavedInstanceState() and onRestoreInstanceState() in activity?
- onSavedInstanceState() - This method is used to store data before pausing the activity.
- onRestoreInstanceState() - This method is used to recover the saved state of an activity when the activity is recreated after destruction. So, the onRestoreInstanceState() receive the bundle that contains the instance state information.
-
What is
Fragment
and its lifecycle. - Learn from here -
What are "launch modes"? - Learn from here
-
What is the difference between a
Fragment
and anActivity
? Explain the relationship between the two. - Learn from here -
When should you use a Fragment rather than an Activity?
- When you have some UI components to be used across various activities
- When multiple view can be displayed side by side just like viewPager
-
What is the difference between adding/replacing fragment in backstack? - Learn from here
-
Why is it recommended to use only the default constructor to create a
Fragment
? - Learn from here -
How would you communicate between two Fragments? - Learn from here
-
What is retained
Fragment
?- By default, Fragments are destroyed and recreated along with their parent Activity’s when a configuration change occurs. Calling setRetainInstance(true) allows us to bypass this destroy-and-recreate cycle, signaling the system to retain the current instance of the fragment when the activity is recreated.
-
What is the purpose of
addToBackStack()
while commiting fragment transaction?- By calling addToBackStack(), the replace transaction is saved to the back stack so the user can reverse the transaction and bring back the previous fragment by pressing the Back button. For more Learn from here
-
What is
View
in Android? - Learn from here -
Difference between
View.GONE
andView.INVISIBLE
? - Learn from here -
What are ViewGroups and how they are different from the Views?
- View: View objects are the basic building blocks of User Interface(UI) elements in Android. View is a simple rectangle box which responds to the user’s actions. Examples are EditText, Button, CheckBox etc. View refers to the android.view.View class, which is the base class of all UI classes.
- ViewGroup: ViewGroup is the invisible container. It holds View and ViewGroup. For example, LinearLayout is the ViewGroup that contains Button(View), and other Layouts also. ViewGroup is the base class for Layouts.
-
What is a Canvas? - Learn from here
-
Tell about Constraint Layout - Learn from here
-
Do you know what is the view tree? How can you optimize its depth? - Learn from here
-
How does RecyclerView work internally? - Learn from here and here
-
What is the ViewHolder pattern? Why should we use it? - Learn from here
-
What is
Dialog
in Android? - Learn from here -
What is
Toast
in Android? - 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 the function of an
IntentFilter
? - Learn from here -
What is a
PendingIntent
?- If you want someone to perform any Intent operation at future point of time on behalf of you, then we will use Pending Intent.
-
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 can you use for background processing in Android? - Learn from here
-
How to run parallel tasks in Java or Android, and get callback when all complete? - Learn from here
-
Why should you avoid to run non-ui code on the main thread? - Learn from here
-
What is ANR? How can the ANR be prevented? - Learn from here
-
How does the threading work in Android? - Learn from here
-
Android Memory Leak and Garbage Collection - Learn from here
-
How to persist data in an Android app? - Learn from here
-
How would you preserve
Activity
state during a screen rotation? - Learn from here -
What are different ways to store data in your Android app? - Learn from here
-
Explain Scoped Storage in Android. - Learn from here
-
How to encrypt data in Android? - Learn from here
-
What is commit() and apply() in SharedPreferences?
- commit() returns a boolean value of success or failure immediately by writing data synchronously.
- apply() is asynchronous and it won't return any boolean response. If you have an apply() outstanding and you are performing commit(), then the commit() will be blocked until the apply() is not completed.
-
How to generate dynamic colors based in image? - Learn from here
-
Explain about Density Independence Pixel - Learn from here
-
How do you find memory leaks in Android applications? - Learn from here and here
- How do you support different types of resolutions? - Learn from here
-
What is Android Jetpack and why to use this? - Learn from here
-
What are Android Architecture Components? - Learn from here
-
What is LiveData in Android? - Learn from here
-
How LiveData is different from ObservableField? - Learn from here
-
What is the difference between setValue and postValue in LiveData? - Learn from here
-
How to share ViewModel between Fragments in Android? - Learn from here
-
Explain Work Manager in Android. - Learn from here
-
Use-cases of WorkManager in Android. - Learn from here
-
How ViewModel work internally? - Learn from here
-
How do you troubleshoot a crashing application? - Learn from here
-
What is Android Data Binding? - Learn from here
-
Why do we use the Dependency Injection Framework like Dagger in Android? - Learn from here
-
How does the Dagger work? - Learn from here and here
-
What is Component in Dagger? - Learn from here
-
What is Module in Dagger? - Learn from here
-
What is Flow in Kotlin? - Learn from here
-
Describe MVVM. - Learn from here and here
-
What is presenter? - Learn from here
-
What is model? - Learn from here
-
Describe the repository pattern - Learn from here
-
Tell something about clean code - Learn from here
-
Explain unit test. - Learn from here
-
Have you done unit testing or automatic testing?
-
Why mockk (new alternative of Mockito) is used Learn from here
-
Describe JUnit test. - Learn from here
-
Describe code coverage. - Learn from here
-
What is ADB? - Learn from here
-
What is Lint? What is it used for? - Learn from here
-
Git. - Learn from here
-
Android Development Useful Tools. - Learn from here
-
Firebase. - Learn from here
-
How to use Firebase realtime database in your app? - Learn from here
-
What is Gradle? - Learn from here
-
Explain OOP Concepts.
- Object-Oriented Programming is a methodology of designing a program using classes, objects, inheritance, polymorphism, abstraction, and encapsulation.
-
Tell some advantages of Kotlin. - Learn from here
-
What is the difference between
val
andvar
? - Learn from here -
What is the difference between
const
andval
? - Learn from here -
How to ensure
null
safety in Kotlin? - Learn from here -
When to use
lateint
keyword used in Kotlin? - 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 and here
-
What are
companion objects
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
-
What is a data class in Kotlin? - Learn from here
-
How to create a Singleton class in Kotlin? - Learn from here
-
What is the difference between
open
andpublic
in Kotlin? - Learn from here -
Explain the use-case of
let
,run
,with
,also
,apply
in Kotlin. - 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 is an
Init
block in Kotlin? - Learn from here -
Explain
pair
andtriple
in Kotlin. - Learn from here -
How to choose between
apply
andwith
? - Learn from here -
How to choose between
switch
withwhen
? - Learn from here -
What are Coroutines in Kotlin? - Learn from here
-
What is Coroutine Scope? - Learn from here
-
What is Coroutine Context? - Learn from here
-
Launch vs Async in Kotlin Coroutines - Learn from here
-
What is inline function in Kotlin? - Learn from here
-
When to use Kotlin sealed classes? - Learn from here
-
Explain function literals with receiver in Kotlin? - Learn from here
-
What are higher-order functions in Kotlin? - Learn from here
-
What are Lambdas in Kotlin - Learn from here
Copyright (C) 2020 MINDORKS NEXTGEN PRIVATE LIMITED
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.
Just make pull request. You are in!