Android Interview Questions

Ratings:
(4.3)
Views:1451
Banner-Img
  • Share this blog:

Android Interview Questions and Answers

Q1: List out the Java classes that are related to the use of sensors on the android platform.

Ans: There are four Java classes that are related to the use of sensors on the Android platform are as follows:

  • Sensor: It provides methods to identify the capabilities that are available for a specified sensor and can create an instance of specific sensor
  • Sensor Manager: It provides methods for registering sensor event listeners and calibrating sensors
  • Sensor event: It is used to create a sensor event object and provides the raw sensor data, accuracy of data, type of sensor that generate the event, and timestamp for an event
  • Sensor event listeners: This interface is to create two callback methods that receive notification when the sensor value changes or when sensor accuracy changes

Q2: What is the intent? 

Ans: An intent is a messaging object which you can use to request an action from another app component. It is used for starting an activity, Services, or delivering a broadcast. There are two types of intents in android.

They are:

  • Implicit intent
  • Explicit intent

Q3: What is the Contentprovider?

Ans: A ContentProvider manages access to a structured set of data. A provider is a part of an Android application, which often provides its own UI for working with the data. Content providers are primarily intended to be used by other applications that can access the provider by using a provider client object.

Q4: What is DDMS? Mention some of its capabilities?

Ans: DDMS is the Dalvik Debug Monitor Server. It is the bug monitoring server that comes along with android. It provides a wide range of debugging features such as

  • Screen capture
  • Port forwarding services
  • Network traffic tracking
  • Incoming call and SMS spoofing
  • Location data spoofing
  • Simulating network state, speed, and latency
  • Thread and heap information
Want to acquire industry skills and gain complete knowledge of Android? Enroll in Instructor-Led live Android Development Training to get Job Ready!

Q5: Which method is called only once in a fragment lifecycle?

Ans: onAttached() is the method that can call only once in a fragment lifecycle.

Q6: What is a broadcast receiver?

Ans: The broadcast receiver is a dormant component of the Android system. It is responsible to send a notification to the user whenever a specific event occurs like “Check your internet connection”, “Your battery is low”, etc.

Q7: Explain Android application architecture?

Ans: The following are the components of Android application architecture:

  • Services: It is used to perform background functionalities
  • Intent: It is used to perform interconnection between activities and data passing mechanism
  • Content providers: It is used to share the data between applications
  • Notifications: Through light, sound, dialog box, icon, notification and toast
  • Resource externalization: strings and graphics

Q8: Mention the various storages that are provided by Android?

Ans: The various storages that are provided by Android are as follows:

  • Internal storage
  • External storage
  • Shared preferences
  • Network connection
  • SQLite database

Q9: What is the APK format?

Ans: Android Packaging key (APK). It is a compressed key with classes, supportive assets, UI’s, and manifest. All the files can be compressed into a single file called the APK.

Q10: What are the types of flags that are used to run the application?

Ans: There are two types of flags that are used to run the application. They are as follows:

FLAG_ACTIVITY_NEW_TASK

FLAG_ACTIVITY_CLEAR_TOP

Q11: Name the dialog box that is supported by Android?

Ans: The following are the dialog box that is supported by the Android:

  • Progress dialog box
  • Alert dialog box
  • Date picker dialog box
  • Time picker dialog box

Q12: What are the basic tools that are used to develop an Android application?

Ans: The basic tools that are used to develop an Android application are as follows:

  • SDK
  • JDK
  • Eclipse+ADT plugin

Q13: Mention some exceptions in Android?

Ans: Some exceptions in Android are as follows:

  • Inflate Exception
  • Surface.OutofResource Exception
  • SurfaceHolder.BadSurfaceType Exception
  • WindowManager. BadTokenException

Q14: Give a list of impotent folders in Android?

Ans: The list of impotent folders are as follows:

  1. AndroidManifest.xml
  2. Build.xml
  3. bin/
  4. assets/
  5. src/
  6. res/

Q15: What are the core building blocks of android?

Ans: The core building blocks of an android are as follows:

  • Activity
  • View
  • Intent
  • Fragment
  • Service
  • Content provider
  • AndroidManifest.xml

Q16: What are the advantages of android?

Ans: The main advantages of android are as follows:

  • It is an open-source application that can create, distribute, and develop the application for free.
  • It supports Windows, Mac, and Linux platforms
  • It supports various technologies like camera, Bluetooth, wi-fi, EDGE, etc.
  • It uses a highly optimized virtual machine for mobile devices, called DVM (Dalvik Virtual Machine)

Q17: Why byte code cannot be run in android?

Ans: Because android uses DVM (Dalvik Virtual Machine) rather than JVM (Java Virtual Machine).

Q18: Explain the difference between onCreate and onStart?

Ans: onCreate() method is called when the application starts, once during the Activity lifecycle, or when the Activity has been destroyed and recreated, for example during the configuration change.

onStart() method is called whenever the Activity becomes visible to the user, typically after onCreate() or onRestart() method.

Q19: Explain services?

Ans: A service is an application component that can run in the background, even when the user is not interacting with the application. There are three different types of services. They are as follows:

  • Foreground service: It performs the operation that is noticeable to the user. For example, we use a foreground service to play an audio track. Notification must be displayed to the user.
  • Background service: It performs an operation that does not notice directly by the user. In Android API level 26 and above, there are few cases that restrict the use of background service and it is recommended to use WorkManager in such cases.
  • Bound service: A service is bound when an application binds to it by calling bindService(). It offers a client-server interface that allows components to interact with the service, send requests, and receive results. 

Q20: Mention the difference between the Service and Intent service?

Ans: Service is an application component that can run in the background, even when the user is not interacting with the application. A service can handle the network transactions, or can interact with a content provider, all from the background.

Intent service is a subclass of service that handles asynchronous requests on demand. Clients send the requests through intent calls. The service is started as needed, handles each intent inturn using a worker thread and stops by itself when it runs out of work.

Q21: Difference between thread and  Async Tasks?

Ans: Threads is used to separate long running operations from main thread so that to improve the performance. But it can’t be cancelled and it can’t handle configuration changes of an android.

Async Tasks are used to handle work items shorter than 5mins duration and you can update UI unlike Java. but many long running tasks will drown the performance.

Q22: Difference between Activity and Service?

Ans: Activity is basically a container or Windows to the User interface, whereas Service is a component that is used to perform operations on the background.

Q23: Difference between Serializable and parcelable?

Ans: Serializable is  a process of converting an object into streams of bytes in order to store the object in memory, so that it can be recreated but still keeps the object’s original state and data. It is a Standard Java interface.

Parcelable is an android specific interface where you can implement a serialization interface by yourself. This mechanism tends to form a lot of temporary objects and can result in garbage folders. 

Q24: Explain fragments?

Ans: The fragment is a UI entity connected to FragmentActivity. Yourself can connect the various fragments in a single action to create a multi-pane UI and can reuse the fragment in various activities.

Q25: Difference between fragment and the activity?

Ans: An activity is an application component that provides a screen with which the user can interact in order to do something, whereas fragment represents the portion of UI in an activity with its own lifecycle and the input events.

Q26: Explain ANR and how can you prevent them from the app?

Ans: An ANR dialog box occurs when the UI is not responding for more than 5seconds, it usually occurs when you have blocked the main thread. 

To avoid occurring the ANR errors, you should move work off the main thread as much as possible.

Q27: What are the permission protection levels in android?

Ans:

  • Normal: A lower risk permission that provides requesting application access to isolated application level features, with minimal risk to other applications, users, or the system. The system automatically grants this kind of permission to a requesting application at installation, without asking the user approval.
  • Dangerous: It is used when the app wants the data and resources that contains user private information. So the dialog of this license is to be allowed by the user except the app cannot present functionality that depends on the license. 
  • Signature: The system allows these app licenses at the moment of installation, but only when the app that strives to use license that is confirmed by the same certificate as the app that represents the signature permission.

Q28: Explain Loader API in android?

Ans: The Loader API allows you to load the data from the Content provider or other data source for display in an FragmentActivity or Fragment. 

  • It simplifies thread management by providing call back methods when an event occurs. 
  • It persists and cache results across configuration changes to avoid duplicate queries. 
  • It runs on separate threads to prevent unresponsive UI.

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox