Most frequently asked Android Interview Questions and Answers
In this rapidly growing technology, there is a huge demand for android and android developers. As we all know all the things nowadays moving on smartphones and most of the people having android smartphones. That is the reason for the high paid job for an android application developer. In this article, I am sharing some of the most frequently asked android interview questions and answers in MNCs and startups.
Let’s get started for some most improtant android interview questions for both freshers and experienced professionals.
What is Android?
Ans: Android is an open-source operating system based on Linux kernel which is specially designed for cell phones and tablets later on TVs and watches.
What is the Android SDK?
Ans: Android SDK is a toolset for android developers to develop apps for android devices. It contains a graphical interface to emulate the Android environment which helps developers to test and debug the codes.
What is Android Architecture?
Ans: It is having 4 layers which are given below.
- Linux kernel
- Android Framework
- Android Applications
Which programming language is used for android apps development?
Ans: Java and kotlin are the official programming language for android apps development apart from them C and C++ are used for NDK which is native development.
What is the APK format?
Ans: APK stands for Android Application Package. It is compressed file format of application code, resource file, certificates, and other files.
What are the required components of a new android project?
Ans: The below components are required for a new android project.
- manifest: It contains an XML file.
- build/: It contains build output.
- src/: It contains the code and resource files.
- res/: It contains bitmap images, UI Strings, and XML Layout i.e. all non-code resources.
- assets/: It contains a file which should be compiled into a .apk file.
What are the important core components of android projects?
Ans: The below components are core components for an android project.
- Content Provider
What is Activity?
Ans: Activities are containers or windows to the user interface.
What is the Lifecycle of an Activity?
Ans: The below methods are used for activity lifecycle.
- OnCreate(): This is when the view is first created. This is normally where we create views, get data from bundles, etc.
- OnStart(): Called when the activity is becoming visible to the user. Followed by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden.
- OnResume(): Called when the activity will start interacting with the user. At this point, your activity is at the top of the activity stack, with user input going to it.
- OnPause(): Called as part of the activity lifecycle when an activity is going into the background but has not (yet) been killed.
- OnStop(): Called when you are no longer visible to the user.
- OnDestroy(): Called when the activity is finishing
- OnRestart(): Called after your activity has been stopped before it is started again.
What’s the difference between onCreate() and onStart()?
Ans. The onCreate() method is called once during the Activity lifecycle, either when the application starts, or when the Activity has been destroyed and then recreated, for example during a configuration change.
The onStart() method is called whenever the Activity becomes visible to the user, typically after onCreate() or onRestart().
Define intents in Android. What are the different types of intents?
An Intent is an “intention” to do an action. An intent is a messaging object you can use to request an action from another app component.
Methods are used to deliver intents to different components:
context.startActivity() – To start an activity
context.startService() – To start a service
context.sendBroadcast() – To deliver a broadcast
Types of Intent:
Implicit Intent: Implicit intent is when the target component is not defined in the intent and the android system has to evaluate the registered components based on the intent data.
Explicit Intent: Explicit intent is when an application defines the target component directly in the intent.
What is the difference between an implicit intent and explicit intent?
Ans: Implicit Intent is used whenever you are acting. For example, send an email, SMS, dial number or you can use a Uri to specify the data type. For example:
Intent i = new Intent(ACTION_VIEW,Uri.parse(“http://www.edureka.co”));
Explicit, on the other hand, helps you to switch from one activity to another activity(often known as the target activity). It is also used to pass data using the putExtra method and retrieved by other activity by getIntent().getExtras() methods.
Intent i = new Intent(this, Activitytwo.class); #ActivityTwo is the target component
i.putExtra(“Value1″,”This is ActivityTwo”);
i.putExtra(“Value2″,”This Value two for ActivityTwo”);
What is Toast?
Ans: Toast notification is a message that pops up on the window and automatically fades in and out and does not accept interaction events.
What is an ANR? What are some measures you can take to avoid ANR?
Ans: ANR stands for ‘Application Not Responding’. This dialogue is displayed if the main thread in the application has been unresponsive for a long time and in the following conditions:
When there is no response to an input event after 5 seconds.
When a broadcast receiver is not done executing within 10 seconds.
Following measures can be taken to avoid ANR:
To avoid ANR, an app should perform a lengthy database or networking operations in separate threads.
One technique is to create a child thread to prevent the Android system from concluding a code that has been unresponsive for a long period. Most of the actual workings of the codes can be placed within the child thread to ensure that the main thread runs with minimal unresponsive time.
For background task-intensive apps, you can alleviate pressure from the UI thread by using the IntentService.
What are broadcast receivers?
- Broadcast Receiver is a mechanism using which host application can listen for System-level events.
- A broadcast receiver is used by the application whenever they need to perform the execution based on system events. Like listening for Incoming call, SMS, etc.
- Broadcast receivers help in responding to broadcast messages from other application or the system.
- It is used to handle communication between the Android operating system and applications.
What is the use of WebView in Android?
Ans: WebView is a view that display web pages inside your application. According to Android, “this class is the basis upon which you can roll your web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more. To add WebView to your application, you have to add an element to your XML layout file.
What are the different storage methods in Android?
Ans: Android offers several options to see persistent application data. They are:
Shared Preferences – Store private primitive data in key-value pairs
Internal Storage – Store private data on the device memory
External Storage – Store public data on the shared external storage
SQLite Databases – Store structured data in a private database
What is a Service?
Ans: A service in android is a background process which is used to perform long-running operations. Let’s say, a service of location is active in the background while the user is in a different application. So it does not disturb the user interaction with an activity. Now, services are classified into two types, namely:
Local: This service is accessed from within the application.
Remote – This service is accessed remotely from other applications running on the same device.
What is the difference between a fragment and an activity?
Ans: Activity is typically a single, focused operation that a user can perform such as dial a number, take a picture, send an email, view a map, etc.
The fragment is a modular section of an activity, with its lifecycle and input events, and which can be added or removed at will. Also, a fragment’s lifecycle is directly affected by its host activity’s lifecycle i.e. when the activity is paused, so are all fragments in it, and when the activity is destroyed, so are all of its fragments.
Can you change the name of an application after its deployment?
Ans: It is not recommended to change the application after its deployment. This may break some functionality.
What database is used in Android? How does it differ from client-server database management systems?
Ans: SQLite is the open-source relational database. The SQLite engine is serverless, transactional, and self-contained.
Instead of the typical client-server relationship of most database management systems, the SQLite engine is integrally linked with the application. The library can also be called dynamically and makes use of simple function calls that reduce latency in database access.
What are the dialog boxes that are supported in Android?
Ans: Android supports four dialog boxes:
AlertDialog: An alert dialog box supports zero to three buttons and a list of selectable elements, including checkboxes and radio buttons. Among the other dialog boxes, the most suggested dialog box is the alert dialog box.
ProgressDialog: This dialog box displays a progress wheel or a progress bar. It is an extension of AlertDialog and supports adding buttons.
DatePickerDialog: This dialog box is used for selecting a date by the user.
TimePickerDialog: This dialog box is used for selecting time by the user.
What are the exceptions in android?
Ans: InflateException: When error conditions occur this exception is thrown.
Surface.OutOfResourceException: When a Surface is not created or resized, this exception is thrown.
SurfaceHolder.BadSurfaceTypeException: When invoked on a Surface ‘SURFACE_TYPE_PUSH_BUFFERS’, this exception is thrown from lockCanvas() method.
WindowManager.BadTokenException: This exception is thrown at the time of trying to view an invalid WindowManager.LayoutParamstoken
What does ADB stand for?
Ans: ADB stands for Android Debug Bridge. It is a command-line tool that is used to communicate with the emulator instance. ADB can control your device over USB from a computer, copy files back and forth, install and uninstall apps, run shell commands, and more.
It is a client-server program that includes three components:
• Client – which runs on your development machine. You can invoke a client from a shell by issuing an ADB command. Other Android tools such as DDMS also create ADB clients.
• Server, which runs as a background process on your development machine. The server manages communication between the client and the ADB daemon running on an emulator or device.
• Daemon, which runs as a background process on each emulator or device instance.
These were the some most frequently asked android interview questions and answers. for more articles kindly visit Gemini Soft Services .
Blogger | Coder | Speaker
I’m a core Android Developer with complimenting skill as a Web Developer from India.
A general problem solver, I like new challenges and loves to solve unconventional problems. I have a strong formal CS background and extensive experience in several programming languages and environments, as well as sales, marketing, and business.