Android Interview Questions and Answers
In this tutorial, you’ll learn Android-specific interview questions and answers. By Evana Margain Puig.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
Android Interview Questions and Answers
30 mins
- Getting Started
- Android
- What Is the Android Manifest?
- What Is the Gradle Build System?
- What Are Activities and Fragments?
- What Is the App Lifecycle?
- What are Configuration Changes and When Do They Happen?
- Design
- How Do You Manage Resources for Different Screen Sizes?
- What Are Layouts in Android?
- What Is a RecyclerView?
- What Are Support Libraries?
- What Is an Intent?
- What Is Localization? How Do You Do It in Android?
- What Is Android Jetpack?
- What are Android Architecture Components?
- Other Libraries
- Where Do You Organize Your Tests in Android?
- Kotlin
- What Are Coroutines?
- What Are Companion Objects?
- How and When Do You Use Nullables in Kotlin?
- How Do You Do Type Checking in Kotlin?
- How Do You Declare Switch Statements in Kotlin?
- What Is a Lambda Expression?
- When Is the Keyword it Used in Lambda Expressions?
- What Is a Class Extension?
- What Are Ranges in Kotlin?
- Object-Oriented Programming
- What Is Polymorphism?
- What Is the Difference Between a Class and an Object?
- What Are Data Classes?
- What Is Encapsulation?
- What Are Visibility Modifiers?
- Where to Go From Here?
What Are Support Libraries?
Android Support Libraries are packages that contain code. They support a specific range of Android platform versions and sets of features. Most of these support libraries are now part of the androidx
namespace. This is the recommended set of libraries to use.
What Is an Intent?
Intents are messaging objects that trigger actions from other components. These target components can include services and activities.
Explicit Intent
An explicit intent specifies a particular destination for fulfillment. You can direct your intent to an external app. But an explicit intent commonly targets another component within your app. When using an explicit intent, your code must provide the name of the target app or component.
Implicit Intent
An implicit intent does not specify the target component. Instead, it states an action to perform. The Android system directs the intent to an external app capable of fulfilling it. For example, if your app needs to send an email, the Android system will select options from the email apps installed on the device. The user can select the desired email app.
Intents can be as simple or as complex as you want. For more information, you can review our Android Intents Tutorial with Kotlin.
What Is Localization? How Do You Do It in Android?
Localization is the ability of an app to support multiple languages, time zones, currencies, number formats, etc. This allows you to distribute your app widely to different countries and populations. Your app can bundle its localization through using Android’s resource directory framework, which specifies items (strings, images, layouts…) for different locales.
We also have a detailed tutorial on this topic, Android Localization: Getting Started.
What Is Android Jetpack?
Jetpack is a suite of libraries released by Android in 2018. Jetpack’s libraries provide code that works across the many Android devices currently in use. This makes it easy for developers to adhere to best practices!
If you’re new to Android Jetpack, please see our tutorial Introduction to Android Jetpack for help.
Otherwise, let’s go check the most important libraries in Jetpack and the ones you may need in an interview.
What are Android Architecture Components?
Architecture Components are a collection of libraries included in Jetpack. They help you implement clean architecture in your app, based primarily on the MVVM (Model-View-ViewModel) pattern.
We have many tutorials on architecture components, but you can start with this one: Android Jetpack Architecture Components: Getting Started.
What is Data Binding?
The Data binding library helps you bind UI components in your layouts to data sources in your app. It uses a declarative format.
For an explanation on how to use data binding, take a look at Data Binding in Android: Getting Started, by me! :]
What Is View Binding?
View binding replaces findViewById
. It uses binding classes to do this. These classes contain references to all views that have an ID in the corresponding layout.
You can learn more about view binding in our View Binding Tutorial for Android: Getting Started.
What Is LiveData?
LiveData
is an observable class. The advantage of LiveData over libraries like Rx is that it is lifecycle-aware. It only updates data in the STARTED
or RESUMED
state.
LiveData is closely related to coroutines, covered elsewhere in this article. If you want a better understanding of how everything works together, see our article Coroutines with Lifecycle and LiveData.
What Is Room?
Room is a persistence library built over SQLite to help you create databases more easily. Room uses caching to persist your app’s data locally. This provides the app with consistent data, regardless of internet connectivity.
What Is ViewModel?
ViewModel
is a class that stores the data from your UI. Because it’s aware of the app’s lifecycle, ViewModel
is able to persist UI data through configuration changes, such as screen rotations.
What Is the Navigation Component?
The navigation component is a framework that controls navigation within an Android app. It manages the back stack. It also handles functions with different controls, such as the app bar or drawers. The navigation component helps you provide a consistent user experience by enforcing established navigation principles.
Other Libraries
In the Android world, you’ll encounter many libraries in addition to those in Jetpack. Your interviewer may ask about these. Here are some of the most common:
- Libraries for network requests: Retrofit, GraphQL
- Libraries for images: Picasso
- Dependency Injection: Dagger
- Reactive Programming: RXJava and RXKotlin
Where Do You Organize Your Tests in Android?
When you create an Android Studio project, you create two directories for testing:
- The
test
directory is for unit tests that run locally. Usually, the JVM runs these tests. - The
androidTest
directory is for tests that run on devices. You’ll use this directory for other kinds of tests, such as integration tests and end-to-end tests.
What Are Unit Tests? How Do You Do Them in Android?
Unit tests run locally. Since they aren’t run on a device, they don’t have access to any Android framework library. It’s possible to use libraries that allow you to call Android framework methods from unit tests, however these libraries substitute only simulate device behavior. The preferred libraries are either JUnit or Mockito.
The ability to design and implement unit testing is usually a requirement for mid-senior to senior levels. If you want to learn how to do this, here are some resources:
- JUnit is the standard java library for testing, which is usually coupled with AndroidX Test. This is covered in our tutorial Test-Driven Development Tutorial for Android: Getting Started.
- Mockito is another popular open-source testing framework. You can learn more about it in our tutorial Android Unit Testing with Mockito.
Understanding how to use either of these test libraries will be enough for interviews.
Instrumentation Tests
Instrumentation tests are quite similar to unit tests but depend on a device or simulator to run. Since instrumentation tests are run on device, you have access to the Android device libraries. The two libraries mentioned above, JUnit and Mockito, are also used for instrumentation tests.
UI Tests
UI tests simulate a user’s interactions with your UI. The most popular library for testing is Espresso. You can learn about UI testing in our tutorial
Espresso Testing and Screen Robots: Getting Started.