Android interview questions for beginners


Any interview experience is often followed by jitters and nervousness. So, if you’re sitting for an Android interview, allow us to get your nervousness in control by walking you through the 10 most frequently asked Android interview questions for beginners. These Android Interview Questions will help you in building for the interviews:

  1. What do you mean by Android? Also, explain the main components.

Android is an open-sourced OS that enables the development of mobile applications. It is based on Linux and allows users to create and run applications on mobile with the rich high-end components it has. Android has the following main components:

– Linux Kernel
– Android framework
– Android applications
– Libraries

These components enable the developer to create high-end applications which provide all the facilities in a single application with amazing look and feel.

2. What are the important items in an Android project and explain the importance of XML based layouts?

The most important items of any Android project are as follows:
– Androidmanifest.xml
– Build.xml
– bin/
– src/
– res/
– assets/

The two XML files are helpful in providing a consistent layout. They give developers a standard graphical definition format. Generally, all the layout details are placed in these files and other items are placed in the source files.

3. Briefly explain the files and folders that are created during Android project creation.

Src – It contains the java source code for the newly created project. The code for the application that is to be created is also written in this file. It should be made available under the name of the project.
Assets – This folder contains all the relevant information regarding HTML and text files and databases.

Gen – This folder contains the file. This file is generated by the compiler and references the resources that are found in the project. This should not be modified as it is computer-generated.
Android library – This folder contains an android.jar file. This file contains all the libraries required for creating an Android application.
Bin – It contains the .apk file that is created by ADT during the code build process.
Res – This folder contains all the resource files used by the application. It contains subfolders like drawable, menu, layout, values, etc.

  1. What is ANR? What are the precautions to be taken to avoid ANR in an application?

    ANR is a dialog that Android shows when an application isn’t responding. It’s short for Application Not Responding. Usually, this state is achieved when the application is working on many tasks on the main thread and has been unresponsive for a long period of time.

Take care of the following things to avoid ANR:

  1. Ensure that there are no infinite loops in case of complex calculations.
  2. Define HTTP timeout for all web services and API calls in order to ensure that the server does not stop responding.
    3) Use IntentService ifthere are many background tasks. They should be taken off the main UI thread.
    4) Keep all database and long-running network operations on a different thread.

    5. Write code for a Toast with the message  “Hello, this is a Toast”.

Toast.makeText(getApplicationContext(), “Hello, this is a Toast”,

6. Write code to generate a button dynamically.

protected void onCreate(Bundle newInstanceState) {


Button button = new Button(this);




7. What is AIDL? What are the different data types that AIDL supports?

AIDL is short for Android Interface Definition Language. It is an interface between a client and a service that allows them to communicate using interprocess communication (IPC). It involves breaking the objects into smaller parts that allow Android to understand those objects. This happens because a process cannot access memory of other processes that are running.

Types of data supported by AIDL are:

all data types like int, long, char, Boolean.

8. How would you check for the presence of a Compass sensor on the system using the hasSystemFeature() method?

The sensor framework that forms a part of Android package has Sensor and SensorManager classes. But these classes do not provide the hasSystemFeature() method. So they cannot be used for evaluating a system’s capabilities. The PackageManager class can, in fact, be used to find out information about the application packages available on a given device. One way of checking the presence of a Compass sensor on the system is
PackageManager myCompass = getPackageManger();
If (!myCompass.hasSystemFeature(PackageManager.FEATURE_SENSOR_COMPASS))
// This device lacks a compass, disable the compass feature

9. Name some exceptions in android?
– Inflate Exception- This exception is thrown by an inflator on error conditions.
– Surface.OutOfResourceException – This Exception is thrown when a surface couldn’t be created or resized.
– SurfaceHolder.BadSurfaceTypeException– This exception is thrown from lockCanvas() when called on a Surface whose type is SURFACE_TYPE_PUSH_BUFFERS.
– WindowManager.BadTokenException – This Exception is thrown when trying to add a view whose WindowManager.LayoutParams token is invalid.

  1. What is the difference between Serializable and Parcelable? Which is the best approach in Android?

While developing applications we often need to transfer data from one activity to another. This data needs to be included in a corresponding intent object. Some additional actions are also required to make the data suitable for transfer. For doing that the object should be serializable or parseable. Serializable is a standard Java interface. It is a simple approach where you simply mark a class serializable by implementing the interface and Java automatically serializes it. Reflection is used during the process and a lot of additional objects are created. This leads to a lot of garbage collection and poor performance.
Parcelable interface is a part of Android SDK where you implement the serialization yourself. Reflection is not used during this process and no garbage is created. It is faster because it is optimized for usage on android development, and shows better results.

So, that’s all the basic questions you need to know before sitting for any Android interview. If you stumbled in any of them, we recommend you check out the Android development course offered by Coding Ninjas. It’ll not only clear your basics but also help you scale beyond.

blog banner 1