By 2021, it is predicted that there will be 6300 million smartphone subscriptions. Android and iOS have 90% of the market share. Android development is in demand, and Enrique López-Mañas, speaking at Voxxed Days Zurich, has written a book with basic, intermediate and advanced questions and answers for Android interviews.

This is an extract of some of the questions and answers from “100 Questions and Answers to help you land your Dream Android Job: or to hire the right candidate!“.

Part I

What is an Activity in Android?

An Activity can be understood as a screen that performs a very particular action in an Android application (for example, we use an Activity to login to or to modify our profile). The activities interact with the user, they present a window and present an interactive UI inside (this is done through the function setContentView()). Activities are typically full-screen, but can also be floating screens. They have their own cycle, and are piled within a stack of Activities handled by the operating system.

What is the structure of an Android application?

Please keep in mind that this explanation is specific to Android Studio. Although Android Studio shares many features with other IDEs, it also has its differences (I also think Android Studio/Intellij brings more advantages to a company than an outdated IDE).
In Android Studio, a recently created application contains several modules, one of them being the main application, and others being the libraries. Overall, an Android application contains the following key folders and files:

– assets:

this folder contains different resources such as databases, text files, etc.

– build:

this folder is where all the temporary files are deposited before the application actually compiles. It is removed after a clean operation and renewed with each new build.

– libs:

when there are libraries in individual packages (normally you will deal with .jar libraries) they are included in this folder. Not that this is not a technical requirement, but a de-facto standard.

– src:

all the source files are within this folder. This folder is divided in the subfolders main/java (which includes the source code) and main/res (which includes the android resources).

– build.gradle:

this file includes information about how to build the application.

– AndroidManifest.xml:

the Manifest in Android handles essential information that the system needs to run the application. Some of this information includes:

  • Components of the application. All the Activities, Services, Broadcast Receivers and Content Providers need to be defined in the Manifest.
  • Permissions that the application must have in order to access system functions.
  • Instrumentation classes.

Some of the functionality of the Manifest has been moved to the build.gradle file (such as declaring minimum API version or versionCode).

What is an ADB? Mention at least three operations you can perform with ADB.

ADB stands for Android Debug Bridge, and is a command line tool developed to communicate with Android devices, whether they are emulators or physical devices. There are many different operations we can perform with ADB:

  • Install or uninstall an application from the device.
  • Push or pull a file into or from the device.
  • Access the Logcat of the device.

What is Dependency Injection?

Dependency Injection is a design pattern to implement inversion of control, and to resolve dependencies. Dependency Injection (DI) eliminates boilerplate code (for example, by removing listener) and provides a much cleaner and more effective code.

There are a few DI libraries used in Android development:

ButterKnife and Dagger do not use reflection, but rather compile time annotations. They are therefore faster to develop with.

What is the difference between serializable and parcelable, and which alternative is better to use in Android?

Parcelable is a class that has been specifically designed for Android, and is thus more efficient than Serializable.

Serializable just needs an interface to be implemented, thus being more comfortable for the developer. It does, however, use reflection and it is a slow process. It also creates a few temporary objects and there are some concerns with the garbage collector.

On the other hand, Parcelable generates boilerplate code. Most of the time we will prefer it over Serializable, but performance will come at a cost.

 

Part II

Will be out next week, and will cover SQL attacks, preventing memory leaks, and running an app in multiple processes.

 

questions-and-answers

10 Android Interview Questions and Answers: Part I

Profile photo of voxxed
About The Author
-

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>