Android Interview Questions

Question 1: What is Android?
Answer: Android is an operating system that is mainly used for mobile devices, such as tablets and smartphones. It is a Linux Kernel-based, open-source operating system.

Using the rich components of the system, a developer can create and run applications that can perform basic and advanced operations both on the device.

Question 2: What is the Google Android SDK?
Answer: First, SDK is an acronym for “Software Development Kit.” The Google Android SDK is a set of tools that you can use to develop and run an Android application on an Android enabled device.

The Google Android SDK has a Graphical User Interface that emulates the environment of Android-based devices. This allows Android app developers to test and debug their codes to ensure that everything works fine.

Question 3: Which programming language do developers use in Android app development?
Answer: Officially, Java is used as the programming language for Android app development. Most parts of Android are written in Java, and even its APIs are designed mainly from Java. Therefore, it’s the most widely used programming language for this purpose.

However, since Java can be a little complicated for beginners, there are some other options as well. For instance, you can use C/C++ language using the Android Native Development Kit (NDK). Other than that, you can also use Kotlin.

Question 4: What is “Android Architecture”?
Answer: Android Architecture refers to the different software layers in the Android stack. Its four main layers are Linux Kernel, Libraries, Android Framework, and Android Applications.

These components support mobile device needs, and each layer provides different services to the layer right above it.

Question 5: What is the “Android Framework”?
Answer: The Android Framework is one of the most important aspects of Android Architecture. In this, an Android developer can find all the methods and classes necessary to write applications on the Android environment.

Question 6: What is an APK format?
Answer: APK is an acronym for Application Package Kit. It is a default file format of the Android OS. These files are used to distribute and install middleware and application software onto the Android OS.

They have application code, certificates, resource file, manifest file, and other files compressed in them. These files are archive files in the zip format and have the .apk extension.

Question 7: What is meant by Activity in Android development?
Answer: An Activity is a screen representation of an Android app. It’s what you refer to as the window to a user interface. For every activity, there is a layout file that holds your UI elements. Therefore, activities serve as entry-points for user interaction.

For instance, the Facebook start screen where your login details are asked is an activity.

Question 8: What is meant by Activity Lifecycle in Android?
Answer: When a user interacts with an Android app, it’s activities go through a series of changes. Such a change is one of the 7 stages of the Activity Lifecycle. The 7 states are:

onCreate(): This means that the activity is created.

onStart(): This means that the activity becomes visible to the user.

onResume(): This means that the activity is in the foreground and the user can interact with it.

onPause(): This means that the activity is partially obscured by another activity. In this case, the other activity in the foreground is semi-transparent.

onStop(): This means that the activity is completely hidden and not visible to the user.

onRestart(): This means that the activity is in the process of being visible again to the user after being invisible or stopped.

onDestroy(): This means that the activity is destroyed and removed from the memory.

These stages are also called as callbacks. The Android OS invokes these callbacks to know that an activity’s state has been changed.

Question 9: Are Activities and Fragments the same in Android?
Answer: No. An activity involves a single highly focused operation that is highly focused. For example, an activity can be dedicated to sending an email, taking a photo, or dialing a number.

In contrast, a fragment is said to be a modular section of the activity. It has its input events, which you can add or remove. Also, a fragment has its lifecycle, which is directly affected by the lifecycle of its host activity.

For example, if am activity is in a paused state, all its fragments would also be paused. Similarly, if an activity is destroyed, all its fragments would also be destroyed.

Question 10: Explain under which circumstance fragments are used rather than activity?
Answer: Case 1: If users interface elements are used for diverse activities
Case 2: In the case of many views that can be displayed alongside
Case3: In case of retained fragments, means you have all necessary information related to activity restart

Question 11: What is ANR stands for in Android?
Answer: Application Not Responding is the full form of ANR. Whenever an application is overloaded with multiple functions at a time then ANR notification will pop out on by the Android platform or else if the application is nonresponsive to the user action for a long duration.

Question 12: Briefly explain about Intent? Name its types?
Answer: Intent mainly transfers messages or information between the user and the device. In other words, it assists the user while navigating from one activity to another Its main purpose is to kick start an activity ranging from sending SMS or Email, web page display, and so on.
Androids have two types of intents:
• Implicit Intent
• Explicit Intent

Question 13: Which database used in Android?
Answer: The database used in Android is SQLite. It is present by default in Android so no need for any additional administrative task.

SQLite is an operational database responsible for manipulation, storage, and retrieval of data. Have you heard about SQLiteOpenHelper? It’s nothing but a database meant for creation and management of all versions

Question 14: What kind of dialogue boxes supported by Android?
Answer: There are mainly four types of dialogue boxes :

• TimePickerDialog: This dialogue box is used to choose the time AlertDialog: It mainly consists of 3 buttons. There are also checkboxes and radio buttons to choose the element
• ProgressDialog: It helps in the creation of a progress bar.
• TimePickerDialog: It is a widget used to select the time either in 24 h or AM/PM format. In Android, there are two modes of time picker available-spinner mode and clock mode.
• DatePickerDialog: By using this dialog box you can select the date.

Question 15: What is the building process in Android?
Answer: This is a three-step process mentioned below:
• Step 1: Firstly, the compilation of the resource folder(/res) is performed using an android asset packaging tool (aapt). The output class file that only contains constants is named as R.java.
• Step 2: Afterwards javac is used to assemble the java source code to . class files. These class files are further transformed to Dalvik bytecode using the “dx” tool. At last, you will get classes.dex as the final file
• Step 3: Finally all the input files are congregated into apk file using an android apkbuilder.

Question 16: How debugging is performed on the Android platform?
Answer: The Android platform may crash and it’s critical to understand the underlying factor for this failure. In other words debugging is crucial!

Android Monitor.bat is perfect for debugging android platform. However, there are other debugging tools such as Android DDMS, Eclipse Debugging with ADT, Android with Chrome remote debugging, and so on.

Question 17: Elaborate DDMS?
Answer: DDMS stands for Dalvik Debug Monitor Server. This debugging tool has numerous beneficial features such as logcat, screen capturing, Port forwarding, and a lot more! Your real device and emulator can be debugged using DDMS.

DDMS launching: First of all, open the Android Device Monitor and select the DDMS option.

Question 18: Explain briefly about the Content provider?
Answer: Content provider is a standardized interface that interconnects data from one process to another with code running. Regularly android application keeps its data secret from other applications. However, sometimes it is beneficial to share this data with them.
A Content Provider is a subset of Android application that provides its user interface. The data repository is managed by none other than the content provider! You must use Content Resolver while communicating with the provider as a client.

Question 19: Define services? What are its different types?
Answer: Service is an android application that performs long-running operations in the background independently. No user interface available for this. You don’t even realize that service is running in the background. Services are categorized into three different types:
1. Foreground service: This is something that you are aware of! These operations are noticeable to the user. For instance, you get a notification if an audio track is playing in the background

2. Background service: This remains unnoticeable by the user. However, there are some restrictions on background services. For higher android versions work manager is used.

3. Bound service: Client-server interface is allowed inbound service. Consequently, interaction with services, sending, and receiving results are possible.

Question 20: What is AndroidManifest.xml? Why it is so important?
Answer: AndroidManifest.xml plays a crucial role. Every application must have this file in its root directory. Your Android system requires information such as activity, content providers, services, etc. before running an app. This information is supplied through the AndroidManifest.xml file.

The activities performed by AndroidManifest.xml are:
• Application protection: protect your application and also deals with permission access to the protected part of your application
• Unique Identity: Responsible for Java package naming that act as a unique identifier for the app
• Describe components: Application components are defined such as services, content providers, and so on.
• Android API: Pro-claimed by this app
• Library file: Contain detailed information related to the application

Question 21: How can you solve the crashing issue related to your android application?
Answer: These steps are highly recommended for troubleshooting:

• Check memory space: The main reason for system crashing is insufficient space in your electronic gadget. Clearing up internal space can reduce crashing issue
• Manage your device memory: Every device is different! Few apps run effortlessly on particular mobile but create lots of issues when used in other devices. The most probable reason is that every device has distinctive CPU speed, processing power, and memory management
• Clear cache memory: The temporary solution to insufficient storage is to clear your application data using the Application Manager.
• Compatibility test: It always recommended to test your mobile app on multiple devices to avoid any device-related compatibility issue.

Question 22: How activity will respond when your screen rotates?
Answer: During screen rotation, the current activity is destroyed; Afterwards a new activity is created with a new orientation.
First of all, the onRestart() method is initiated on screen rotation. Afterward, other lifecycle methods initiated. However, the flow remains the same as the activity that was first created

Question 23: What do you mean by AIDL? What kind of data does it support?
Answer: AIDL is the acronym for Android Interface Definition Language. Any remote method can only be created and implemented if passed through a communication interface in AIDL. The main role of AIDL is to enhance interaction between client and service.

Following data types are supported:
• List
• String
• Map
• charSequence
• Java data types ( Ex-INT, Long, Char, Boolean, etc)

Question 24: Name and define the flags type required to run an application in Android?
Answer: There are mainly two flags that are used to run an application. These are:
• FLAG_ACTIVITY_NEW_TASK
• FLAG_ACTIVITY_CLEAR_TOP
FLAG_ACTIVITY_CLEAR_TOP
If the activity you have started is already running or if the old instance of this activity is already present, then all other activities are destroyed or cleared instead of launching a new activity. Finally, this old activity becomes the main part of the task list.
FLAG_ACTIVITY_NEW_TASK
Initiate the activity in a new task. If there is already a task running for your activity, that task will be forefronted with last stage restoration. This activity will get new intent in onNewIntent()

Question 25: Explain about sleep mode in android application?
Answer: During this phase, your application will not respond to any command. CPU (Central Processing Unit) is in the sleep mode or non-working stage. CPU does not accept any commands from the device. However, it responds to a few activities such as alarm and radio interface layer

Question 26: Name different data storage options present on the Android application?
Answer: Android platform has a plethora of data storage options. However, there is some prerequisite for these options such as data security, permission, and public accessibility.

Here are enlisted Android platform’s data storage option:

• SharedPreference: Most simplified option to store your private data. XML files are used to store data.
• SQLite: Deals in structured data storage in a private database.
• Internal Storage: In this case data is stored within the internal storage of the device and no app can’t read it.
• External Storage: Data is stored outside the device in the file system. However, you can access your data at any time and anyplace.

Question 27: Why there is a need to set up permission for app development?
Answer: Permission setup is highly recommended for app development otherwise your data will be accessible to anyone. If you have kept the code with no restriction there are chances of defect leakage. If you set up permissions then your code and data will be accessible to authorized users only.

Question 28: What are the major differences between AsyncTasks & Threads?
Answer:
1. Threads are mainly used for long operations to improve performance. However, you can’t afford configurational changes in the Android. The user interface can’t be updated from the thread.
2. AsyncTask can be used to handle work items shorter than 5ms in duration. With AsyncTask, you can update UI, unlike java Thread. But many long-running tasks will choke the performance.

Question 29: What are the different permission protection levels in the Android application?
Answer: These are the main permission protection level:
1. Normal — Low-risk permission. You will get permission for the particular application while other applications remain protected. In this case, permission is granted by the system automatically without any involvement of the user’s approval
2. Dangerous: High-risk permission. In this case, permission application is displayed to the user and there is no option for an automatic permission grant. This means the user is aware of the permit application.
3. Signature — In this scenario, permission is only granted if the application is signed with the certificate that permission is granted. Permission will be granted automatically if the certificate matches

Question 30: Enlist the core components of the Android operating system?
Answer: The main important components of Android are:
1. Activity
2. views
3. Intents
4. Services
5. Content Provider
6. Fragment
7. AndroidManifest.xml

Activity: It is that part of the mobile app through which users interact with.
Views: It is a user interface element such as button or label
Intent: It assists the user while navigating from one activity to other
Services: It’s a component of Android that runs independently in the background
Content Provider: The central data repository is managed by the content provider
Fragment: Fragments are a subpart of activity, An activity shows multiple fragments on the screen
AndroidManifest.xml: It embraces all details related to activities, content providers etc.

Question 31: What are the different types of notification available in Android?
Answer: There are mainly three kinds of notification that you will encounter on the Android platform. These are enlisted below:
• Status Bar Notification – All notifications on the status bar will be shown here.
• Toast Notification – This kind of notification will pop up as a message on your window’s surface
• Dialogue Notification – This is linked to activity. This is also known as activity related notification.

Question 32: Is there any way out through which mobile leaks can be identified in the mobile app in the Android application?
Answer: Android Device Manager or ADM has specialization to detect memory leaks on the Android platform. You will find ADM in the Android studio.
As you open the Android device Manager you will find your device or emulator on the left-hand side. There you will find a heap sign in the display. If any mobile app is running then you can watch memory analysis, statistics, and heap size displayed on it.

Question 33: Define Orientation?
Answer: Orientation is something that you will find embedded in all smartphones. This feature can move your mobile phone in vertical and horizontal mode.
There are two types of screen orientation available in Android :
• Portrait: Device Vertically aligned.
• Landscape: Device horizontally aligned.

The orientation is defined in the AndroidManifest.xml file by the android developers. Screen alignments can be established using setOrientation() method. In the setOrientation() method only horizontal and vertical values can be used. So, what happened when orientation is changed? The current activity is destroyed and new display orientation is created in the same activity. onCreate() method gets fired.

Question 34: Bytecode cannot be run in Android. Explain?
Answer: Java bytecode cannot be run on android. This is because the Android platform uses DVM (Dalvik Virtual Machine ) and not JVM(Java Virtual Machine).

Question 35: What is the best method to prevent data reloading and resetting when the screen rotates?
Answer: The best possible way out is to use a combination of two models i.e, ViewModels and onSaveInstanceState
• ViewModel: The good point about this is that a view model is LifeCycle-Aware which means it never gets destroyed even if its owner gets vanished. For instance, a ViewModel still exists if its owner gets destroyed due to rotation (change in configuration), and the new instance of the owner re-connects to the existing ViewModel.
• In simplified terms, if you have rotated a screen three times which means three different activity instances, but there will be a single view model for all three.
• Hence, data is stored in ViewModel class and OnSaveInstanceState is used to store small amounts of User Interface data.

Question 36: How data can be accessed using the Content Provider?
Answer: These are the following steps that you should consider for getting access using content provider:
1. First of all, make sure that you have all the necessary read access permissions.
2. Afterwards get ContentResolver object access by calling getContentResolver()
3. Make a query using ContentResolver.query() for data retrieval
4. Finally, you can retrieve data using the cursor method from each column as the ContentResolver.query() method left a cursor

Question 37: Distinguish between Service & Intent Service?
Answer: The main differences are:
• Service: This is the main class for Android services. It also creates other services through extensions. If a class extends Service runs on the main thread it can block the User Interface so that it can be applied for short tasks. Otherwise, it can use other threads for longer tasks.
• IntentService: is a subcategory of Service. It mainly deals with asynchronous requests or Intent on demand. Requests are received through startService(Intent) calls from the Clients. In this case, service is started as per the requirement and uses a worker thread to handle each Intent. It stops itself when there is no work.

Question 38: Name all the different versions of the Android Operating System?
Answer: The different version of the Android Operating System are:

1. Android 4.0-4.0.4: Ice Cream Sandwich
2. Android 4.1 – 4.3: Jelly Bean
3. Android 4.4 – 4.4.4: KitKat
4. Android 5 – 5.1.1: Lollipop
5. Android 6 – 6.0.1: Marshmallow
6. Android 7.0 – 7.1.2: Nougat
7. Android 8.0: Oreo

Question 39: Define ADB?
Answer: ADB is the abbreviation of Android Debug Bridge. This is mainly a command-line tool to deal with shell commands.
There is a need for direct communication between the emulator ports and here ADB came into the picture! It provides direct communication between the emulator port and the developer.

Question 40: Why emulators are used in place of real devices for testing?
Answer: Emulators are mainly used as a substitute for real devices. This is because testing on real devices is sometimes costlier and there are several occasions when new devices are not available for testing. Hence, emulators are used for performing identical testing that has been planned for real devices. This approach has numerous benefits.

Question 41: Which type of scenarios can only be tested on real devices?
Answer: In general emulators are used as an alternative of the real device in testing. However, there are some scenarios where emulators are of new use. We need real devices for testing. These scenarios are known as interrupted scenarios. Some of these are a phone call or message interruption while using any application, low battery, memory card mount, etc.

Question 42: Briefly explain about explicit Intent?
Answer: Android Explicit intent means that you can call another activity in android. In simplified terms, Explicit intent is calling an application activity from other activity. However, the application should be the same.

Question 43: What is an Implicit Intent?
Answer: In the case of Implicit Intent the component is not specified. So, here the intent gives all information about available components that have to be invoked. In other words, Implicit intent is nothing but calling system default intent such as to send SMS, send Email, and dial number.

Question 44: What is a Sticky Intent?
Answer: A communication between a function and a service is permitted through sticky Intent. The sticky Intent or sendBroadcast is performed by sendStickyBroadcast. For instance, the Intent remains there even if the broadcast is complete. While others can gather this data through registerReceiver, an IntentFilter.
For better explanation let’s take an example, you take an intent for ACTION_BATTERY_CHANGED to get battery change events. So, when you call registerReceiver()even with a null BroadcastReceiver — you will get the last broadcast event for that action. Therefore, this broadcast event can be used to determine battery state without unnecessary future events.

Question 45: Under what condition you should use a fragment instead of activity?
Answer: Here is the situation where a fragment is recommended over activity:
• In the case of user interface components that has to be used across many activities.
• In the case of numerous views that have to be displayed simultaneously(viewPagertabs)
• Retained fragments, where data needs to be to be persisted across Activity restarts

Question 46: Enlist all mobile automation testing tools currently available in the market?
Answer: A range of mobile automation tools are present in the market. However, these have to be used as per the project requirement or if your application supports this automation.

These automotive tools can be free of cost or you have to pay for them! Therefore, you should choose the tool with the utmost care. Consultation with the project team is a good idea. Below are mentioned some of the mobile automation tools such as:
Paid automation tool: Silk Mobile, SeeTest, Ranorex
Free mobile automation tools: Appium, KIF, Robotium, Calabash

Question 47: What kind of Sensors are present in Android-enabled devices?
Answer: Mobiles with an android operating system has sensors for numerous activities such as orientation, motion, measure, and so on.

These Built-in sensors have a high grade of accuracy that enables them to monitor the alignment and motion of the device correctly. There are two categories of sensors- hardware-based and software-based.
Sensors are further classified into three types. These are:

• Position Sensors: It mainly includes magnetometers and orientation sensors. Position sensors measure the position of the device.
• Motion Sensors: It mainly includes accelerometers, Gravity sensors, and rotational vector sensors. Motion sensors deal with rotational & acceleration forces measurements.
• Environmental Sensors: This kind of sensor deals with environmental factors such as humidity, pressure and air temperature, etc.

Question 48: What do you mean by Handlers? For what purpose they are used?
Answer: Handlers are objects that are designed to handle threads. Handlers mainly receive messages and write code on handling the message. Handlers are not part of the activity’s lifecycle. Thus, there are chances of thread leak if handlers are not cleaned properly.
• Handlers provide perfect communication between the main thread and background thread
• When you need to perform background tasks on repeated mode then handler class is preferred.

Question 49: Distinguish between onCreate() and onStart()?
Answer: The main difference between onCreate() and onStart() are:
• onCreate method: The onCreate() method is used once during the Activity lifecycle’. It can be used when the application starts or is destroyed. Afterward, the application is again recreated during a configuration change.
• onStart() method: When activity is visible to the user. This method mainly use onCreate() or onRestart().

Question 50: What do you mean by Armv7?
Answer: Android platform mainly has three CPU architectures. These are enlisted below:
1. ARMv7: it is optimized for battery consumption. Most common type
2. ARM64: It takes care of 64-bit processing. Useful in powerful computing
3. ARMx86: It is more powerful than the other. However not used so much due to its poor battery-related features.

Question 51: Describe the Lifecycle of an Activity?
Answer: Lifecycle of activity is explained below:
1. OnCreate(): First of all view is created. Here we create views and get data from bundles etc.
2. OnStart(): This happens when the user can see the activity. Afterward, if activity reaches to the foreground then onResume() or else onStop() in case it is hidden.
3. OnResume(): At this point activity starts interacting with the user. In this situation, your activity has acquired the topmost place of the activity stack, and user input also happening.
4. OnPause(): During OnPause() activity is still running in the background. It has not yet been killed.
5. OnStop(): This is Called when you are not visible to the user.
6. OnDestroy(): When the activity finishes we call OnDestroy()
7. OnRestart(): OnRestart is called when activity is going to start again after getting stopped.

Question 52: Define fragments?
Answer: Fragment is defined as a user interface entity attached to Activity. You can reuse Fragment by attaching it to different activities. An activity can have multiple fragments attached to it. A fragment should always be attached to an activity. A fragment ‘s lifecycle is dependent on host activity.

Question 53: Explain in detail the fragment lifecycle?
Answer: Fragment lifecycle is explained below:
1. onAttach(): Typically, a fragment instance is linked with an activity instance. Hence, the fragment and the activity is not fully started. In onAttach() method you will get a reference to the activity that will use the fragment for upcoming initialization work.
2. onCreate(): This method is called when a fragment is created. Firstly, you should initiate the essential components of the fragment that you want to retain. These elements are helpful to resume when the fragment is paused or stopped.
3. onCreateView(): onCreateView() is used when the user interface is drawn for fragment for the very first time. When you are drawing UI for the fragment you have to return view component which is the root of your fragment’s layout. If no UI is provided by the fragment you can return null.
4. onActivityCreated() : This is called after host activity is created or the onCreateView(). At this occasion activity and fragment instance, both are created. Moreover, the view hierarchy of the activity was also created. FindViewById() method.is called for view
5. onStart() : onStart() method is called once the fragment gets visible.
6. onResume(): Called when Fragment is active.
7. onPause(): This is called when the user is leaving the fragment.
8. onStop(): You can stop any ongoing fragment by calling onStop()
9. onDestroyView(): This method is called when the fragment is destroyed.
10. onDestroy(): This is called for the final clean-up of the fragmented state.

Question 54: Is there any benefit of using the default constructor to create a Fragment?
Answer: You should always pass parameters through the bundle. This will automatically restore your bundle when a system change configuration or restore a fragment. In this way, there is guaranteed restoration of the fragment’s state to the initial fragment state.

Question 55: Distinguish between FragmentPagerAdapter and FragmentStatePagerAdapter?
Answer: The main difference between FragmentPagerAdapter and FragmentStatePagerAdapter are:
• FragmentPagerAdapter: In this case, the fragment of each page is in the memory storage and the view is destroyed. However, the view will be destroyed and this view has to be recreated. There is no need to create fragment instances. In this case, a large amount of energy is being used. When we have to store the whole fragment in memory then FragmentPagerAdapter is used.
• FragmentStatePagerAdapter: This uses a small amount of memory and suitable for handling larger data sets. FragmentStatePagerAdapter should be used in case of dynamic fragments. Examples of dynamic fragments are fragments with widgets. In the case of fragments with widgets, you can store data in the savedInstanceState. Another advantage of this is that there will be no impact on performance even in the case of larger fragments.

Question 56: Explain the importance of XML-based layouts?
Answer: XML-based layouts provide setting GUI definition format that has consistency and a standardized approach. In general practice, XML files contain all layout details while source files contain other details.

Question 57: What are the ways for programming the android app?
Answer: Android apps are not necessarily programmed through Java. You can use the Native Development Kit (NDK) in C/C++. The NDK is a toolset that uses native code language such as C and C++ to implement a certain portion of the app. CPU intensive application use NDK such as physics simulation, Game engines uses NDK toolset.

Question 58: Do the Android platform supports JAR deployments? Which type of packaging is supported by Android?
Answer: JAR deployments are not supported by the android digital platform. With the aid of the Android Asset Packaging Tool (AAPT), applications are packed as .apk files. Afterward, this was used onto the Android platform.
Android Development Tools for Eclipse is provided by Google. This can be further used for android package generation.

Question 59: How can you prevent ANR?
Answer: The best approach to prevent ANR is to create a child thread. This will avoid the android from concluding a code. The maximum actual working of the code will be placed in child thread while the main thread will run unresponsive.

Question 60: Describe the role of Dalvik in Android development?
Answer: Dalvik a virtual machine, present in every Android application run. It is a device that runs multiple virtual machines efficiently. It works through better memory management.

Question 61: How many Java classes are there for the use of sensors in Android development? Give names and explain.
Answer: Following are the four Java classes that are used to use the sensors in Android development
• Sensor
This is class in Java representing a sensor. It uses sensor-manager to get the list of available sensors.
• SensorManager
This is java class which lets you access the sensors in the device.
• SensorEvent
This class represents an event of a sensor and keeps the information related to the sensor’s type, the time-stamp, accuracy and the properties of the SensorEvent class.
• SensorEventListener
SensorEventListener Class represents an interface to receive sensor event notifications.

Question 62: Differentiate Serializable ad Parcelable. Which is the best to use in Android?
Answer: Serialize is a java interface. If you set a class as a serializable entity, Java will automatically make it serializable, call it and use at certain situations. Parcelable is Android interface to set the serialization manually.
It is far better than Serializable because of its efficiency and covering problems with serialization by default.

Question 63: What are “launch modes”? How many mechanisms are there by which they can be defined? Which specific types are supported?
Answer: Launch mode is used to associate the current task with the new instance of an activity. Launch modes can be explained using these mechanisms:
• Manifest file
It is specified that the activity is associated with tasks, when an activity is declared in a manifest file.
Its values are:
Standard
SingleTop
SingleTask
SingleInstances

• Intent flags
Specifies how the new activity should be connected with the current task. Its values are:
FLAG_ACTIVITY_NEW_TASK
FLAG_ACTIVITY_SINGLE_TOP
FLAG_ACTIVITY_CLEAR_TOP

Question 64: List out some characteristics of activity.
Answer: • Activity is always associated with UI.
• No two UIs can have the same activity or vice versa.
• Activity has its own specific life cycle.

Question 65: Explain the purpose and structure of the manifest file.
Answer: Manifest file provides essential information that the system must have to run any of the application’s code.

Question 66: What is Material Design in android?
Answer: • It was introduced in Lollypop Version.
• Materia theme, new widgets, custom shadows, vector drawable and vector animation.
• It is all about that how we create amazing experience to users with positive brand reality.
• It is used for each and every screen like, rectangular, tablet mode, circular watches etc.

Question 67: What is the floating action button?
Answer: This button floats on UI in a circular shape with some actions attached to it.

Question 68: Differentiate between Snackbar and Toast.
Answer: • Snackbar is just like toast message except they provide action to interact with.
• Snackbar will be displayed at the bottom of the screen and can be swiped off in order to dismiss them.

Question 69: How fragments are created?
Answer: • Statically: configuring layout.xml
• Dynamically: Using FragmentManager

Question 70: Explain Lifecycle methods of Fragments.
Answer: • A Fragment must always be embedded in an Activity and the Fragments Lifecycle is directly affected by them.
• Each Fragment can be manipulated independently, such as add or remove them.
• When you perform such a fragment transaction, you can also add it to a back stack that’s managed by the activity.

Question 71: What is ListFragment? How can we use it?
Answer: • A fragment that displays a list of items, by binding to a data source such as an array or Cursor.
• It exposes event handlers when the user selects an item.
• ListFragment hosts a ListView object that can be bound to different data sources.

Question 72: Name 4 different types of Fragment Classes.
Answer: The 4 different types of Fragment Classes are:
• DialogFragment
• ListFragment
• PreferenceFragment
• Single Frame Fragment