10X Sale
kh logo
All Courses

Introduction

Most mobile devices today rely on Android, an open-source Linux-based OS. The Android development process involves developing applications for these Android-based devices. As a result, the demand for Android developers has been at an all-time high. We have compiled a list of commonly asked Android interview questions, and this article is aimed at helping freshers, intermediate and expert Android developers about to appear for interviews.

These top Android interview questions with answers are prepared by Android experts and cover various topics like MVVM, ART, onstraintLayout, fragment, and activity and help you understand the different purposes of AndroidManifest.xml file, to name a few. With these top Android interview questions, you can be confident that you will be well-prepared for your next interview. So, if you are looking to advance your career in App development, this guide is the perfect resource for you.

Android Interview Questions and Answers
Beginner

1. How will you terminate an alive thread?


There is no direct way to terminate a thread but using the two following ways it can be done.

  1. Calling ‘interrupt()’ method on the thread object (e.g. threadObj), this will throw an InterruptedException inside the run method of thread. This exception will indicate that we should release the resources gracefully and then exiting the ‘run’ method of thread will terminate the thread.
  2. In case if the InterruptedException is swallowed by the code or ignored as well as If inside the thread’s ‘run’ method if any looping is there, if yes then adding a method check in that loop that if this thread should exit now or not, is done by checking ‘Thread.currentThread().isInterrupted()’ that returns true and then exit the run method.


2. What is MVVM?

MVVM stands for Model-View-ViewModel. Android applications built using MVVM are more robust, fast, scalable and very less prone to memory leaks. In MVVM ViewModel is the key between View and Model.

Data flow Reference

The important key point about MVVM is that View has reference to the ViewModel but not in reverse and that makes the application’s UI-Components related memory leak-proof. Each View may have a dedicated ViewModel or may be shared by multiple in case of fragments to enable sharing data cross fragments of an activity. MVVM is a more suitable candidate for automated testing.

3. What is ART?

It stands for Android Run Time. ART is used for running Android applications. It uses AOT (Ahead Of Time) compilation on the device. When an APK is getting installed on the Android device, the .dex files from the APK file will be converted to processor’s native instructions set/machine code (.art extension) and that will be stored in the app’s runtime cache directory on the device’s internal storage. This will make installation little bit longer and take more space on the device storage but it makes apps run much faster, less battery consumption, robots application debugging support and better user experience.

4. What is the recommended way to perform discrete, ‘transactional’ background tasks in Android?

The recommended way going forward is using WorkManager APIs, that makes it easy to specify deferrable, asynchronous tasks and when they should run under the circumstances you choose, or recurring tasks that run at a specified interval. Internally WorkManager might use JobScheduler, Firebase-JobDispatcher, Executor, and AlarmManager for running the task.

5. What is Android?

Android is a ‘Linux based software stack’ created for a wide array of devices and form factors. It is open source. It has layers of major components from bottom to top as follows…

  1. The Linux Kernel: It is the foundation of the Android platform
  2. Hardware Abstraction Layer (HAL): It provides standard interfaces that expose device hardware capabilities to the higher-level Java API framework. Vendors/OEMs must explicitly extend the HAL, due to this no need to open source the vendor-specific source code.
  3. Android Runtime (ART) & Native C/C++ Libraries: ART uses Ahead-of-time (AOT) and just-in-time (JIT) compilation to run the android application and Optimized garbage collection (GC) to reclaim memory. It provides better debugging support.
  4. Java API Framework: The entire feature-set of the Android OS is available through APIs implemented using Java language. These APIs form the building blocks to create Android apps by simplifying the reuse of core, modular system components, and services, which include e.g. View System, Resource manager, Notification manager, Activity manager, Content Provider
  5. System Apps: Pre-installed a set of core apps for email, SMS messaging, calendars, internet browsing, contacts, and other apps.

6. What is the purpose of AndroidManifest.xml file?

It is the foundation for any Android application. It will be in app module’s src/main/ directory for Android Studio projects. This file contains information of application package, including components of the application such as activities, services, broadcast receivers, content providers etc. It performs some other tasks also: It is responsible to protect the application to access any protected parts by provision of permissions.

7. What is a layout?

  1. A layout defines the structure for a user interface in an android app, such as in an activity.
  2. All elements in the layout are built using a hierarchy of View and ViewGroup objects.
  3. A View is visible and interact-able whereas a ViewGroup is an invisible container that defines the layout structure for View and other ViewGroup objects under it.

8. What is a fragment?

  1. A Fragment represents a behavior or a portion of user interface.
  2. A fragment must always be hosted in an activity and the fragment's lifecycle is directly affected by the host activity's life-cycle.
  3. When a fragment is added as a part of activity layout, it lives in a ViewGroup inside the activity's view hierarchy and the fragment defines its own view layout.

9. What is a service?


  1. A Service is an application component that can perform long-running operations in the background; it can run in a new process itself or as a part of your application’s process.
  2. It doesn't provide a user interface, but various APIs to interact with it.
  3. Another application component can start a service, and it continues to run in the background even if the user switches to another application.
  4. A component can bind to a service to interact with it and even perform interprocess communication (IPC)


Want to Know More?
+91

By Signing up, you agree to ourTerms & Conditionsand ourPrivacy and Policy

Description

Android is a software package and Linux based OS for mobile devices such as computers, tablets, and smartphones. Is developed by Google and later the OHA (Open Handset Alliance). The goal of the Android project is to create a successful real-world product that improves the mobile experience for end users. For today there are many codes names of Android such a Lollipop, KitKat, Jelly Bean, etc.

Today Android become the indisputable leader of the global smartphone market share. This is mainly due to an increase in the use of smartphones in Countries like India, USA, Brazil, China and many more. One of the important features of Android is the integration of Google products and services.

It’s the best time for you to launch a career in Android development. There’s a healthy supply of jobs, demand for Android apps. The expansion is increasing the demand for mobile application developers, currently, have lots of opportunities for employment. 2018 has been a game the dynamic year for the smartphone market.

So, if you are planning to start your career in Android development then you need to be well prepared with all the possible Android interview questions which could be asked in an Android interview. There are several complicated Android developer interview questions you might come across in the Android interview. This article will equip you to deal with Android interview questions asked in Android developer interviews.

Recommended Courses

Learners Enrolled For
CTA
Got more questions? We've got answers.
Book Your Free Counselling Session Today.