Android most asked interview questions topic-wise Part 5 of. N
1.What is android?
Ans: Android is a mobile operating system based on a modified version of the Linux kernel and other open-source software, designed primarily for touchscreen mobile devices such as smartphones and tablets.
2.Describe android architecture?
3.Evolution of android versions?
//Will be adding a link here to the post
4.What is AAPT?
Ans: AAPT2 (Android Asset Packaging Tool) is a build tool that Android Studio and Android Gradle Plugin use to compile and package your app’s resources. AAPT2 parses, indexes, and compiles the resources into a binary format that is optimized for the Android platform.
5.What is DDMS?
Ans: (Dalvik Debug Monitor Server) A debugging tool from the Android software development kit (SDK). Able to monitor operations in the emulator as well as real devices, DDMS reports the details of each processing thread and time spent whether in the app or Android OS.
6.How DVM works?
Ans: The DVM is a virtual machine to run Android applications. The DVM executes Dalvik bytecode, which is compiled from programs written in the Java language. Note that the DVM is not a JVM. One of the key design principles of the DVM is that it should run on low-memory mobile devices and loads quicker compared to any JVM.
7.What is ART?
Ans: Android Runtime (ART) is the managed runtime used by applications and some system services on Android. ART and its predecessor Dalvik were originally created specifically for the Android project. ART as the runtime executes the Dalvik Executable format and Dex bytecode specification.
8.Advantage of ART over DVM?
Ans: There are some major performance improvements that ART brings which were lacking in Dalvik. But every pros have some cons too. I will try to discuss both the advantages and disadvantages here.
1) Compilation Approach
This is by far the biggest advantage of ART over Dalvik. The old guy Dalvik used Just-In-Time (JIT) approach in which the compilation was done on demand. All the dex files were converted into their respective native representations only when it was needed.
But ART uses the Ahead-Of-Time (AOT) approach, in which the dex files were compiled before they were demanded. This itself massively improves the performance and battery life of any Android device.
In case of Dalvik, whenever you touch an app icon to open it, the necessary dex files gets converted into their equivalent native codes. The app will only start working when this compilation is done. So, the app is unresponsive until this finishes.
Moreover, this process is repeated every single time you open an app wasting CPU cycles and valuable battery juice.
But in case of ART, whenever you install an app, all the dex files gets converted once and for all. So the installation takes some time and the app takes more space than in Dalvik, but the performance is massively improved and battery life is smartly conserved.
2) Boot Time
In case of Dalvik, the cache is built with time the device runs and apps are used as is indicated by the JIT approach. So the boot time is very fast.
But in case of ART, the cache is built during the first boot, so the boot time is considerably more in case of ART. You might see an “Optimizing apps” dialog box sometimes you boot.
3) Space Usage
The space used by apps being run on ART is much more than that of Dalvik. Like a 20 MB app on Dalvik, takes more than 35 MB on ART.
So if you are on a low storage device, then this can be a huge disadvantage for you.
4) ART is Damn Fast
As discussed above, ART is extremely fast and smooth. Apps are very snappy and responsive. Any comparison between Dalvik and ART, will surely make the ART device win by a significant margin.
ART is the answer to all those who argued that iOS is faster and smoother than Android and is also more battery efficient.
9.What is ADB?
Ans: Android Debug Bridge (ADB) is a versatile command-line tool that lets you communicate with a device. The ADB command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device.
10.What is ANR?
Ans: Stands for “Application Not Responding.” ANR is an abbreviation that describes an unresponsive Android app. When an app is running on an Android device and stops responding, an “ANR” event is triggered.
11.What is DEX?
Ans: Android programs are compiled into
.dex (Dalvik Executable) files, which are in turn zipped into a single
.apk file on the device.
.dex files can be created by automatically translating compiled applications written in the Java programming language.
12.What is Multi-DEX?
1.What is the intent?
Intent the object carries information that the Android system uses to determine which component to start (such as the exact component name or component category that should receive the intent), plus information that the recipient component uses in order to properly perform the action
2.Types of intent and uses?
Ans: There are 2 types of intent
- Explicit Intent: An explicit intent is one that you use to launch a specific app component, such as a particular activity or service in your app. To create an explicit intent, define the component name for the
Intentobject—all other intent properties are optional.
- Implicit Intent: An implicit intent specifies an action that can invoke any app on the device able to perform the action. Using an implicit intent is useful when your app cannot perform the action, but other apps probably can and you’d like the user to pick which app to use.
3.What is the intent filter and uses?
Ans: An intent filter is an expression in an app’s manifest file that specifies the type of intents that the component would like to receive. For instance, by declaring an intent filter for an activity, you make it possible for other apps to directly start your activity with a certain kind of intent.
4.What is sticky intent?
Ans: Sticks with Android, for future broadcast listeners. For example, if BATTERY_LOW event occurs then that Intent will stick with Android so that any future requests for BATTERY_LOW, will return the Intent.
5.What is pending intent?
Ans: Pending Intent is actually an object which wraps an Intent to do some future work by another app.
It lets us pass a future Intent to another application and allows that application to execute that Intent as if it had the same permissions as our application, whether or not our application is still around when the Intent is eventually invoked.
A PendingIntent is generally used in cases were an AlarmManager needs to be executed or for Notifications. A PendingIntent provides a mean for applications to work, even after their process exits.
PendingIntent uses the following methods to handle the different types of intents:
PendingIntent.getActivity() : Retrieve a PendingIntent to start an Activity
PendingIntent.getBroadcast() : Retrieve a PendingIntent to perform a Broadcast
PendingIntent.getService() : Retrieve a PendingIntent to start a Service
6.What is the chooser? where it is used?
Ans: The chooser dialog forces the user to select which app to use for the action every time (the user cannot select a default app for the action).
1.What is the application class?
Application class in Android is the base class within an Android app that contains all other components such as activities and services. The Application class, or any subclass of the Application class, is instantiated before any other class when the process for your application/package is created.
2.Significance of having application class?
Ans: In application class we can initialise components which are used globally
3.When the application class onCreate() method gets called?
Ans: It gets call whenever application package is created and anything notifies the app.
3.What all things we should define or declare in application class?
Ans: The componets or third party libs which needs commonly in your application.
4.Use of onLowMemory() method of application class?
Ans: This is called when the overall system is running low on memory, and actively running processes should trim their memory usage. While the exact point at which this will be called is not defined, generally it will happen when all background process have been killed. That is, before reaching the point of killing processes hosting service and foreground UI that we would like to avoid killing.
You should implement this method to release any caches or other unnecessary resources you may be holding on to. The system will perform a garbage collection for you after returning from this method.
- What is the manifest file in the android project?
- What is the use of a manifest file?
- What do all things need to define in the manifest file?
- What is R.java stand for?
- What is Gradle?
- what all things need to define in build.Gradle file?
- What is the build flavor?
- What is the build type?
- What is Gradle wrapper?
- What is multidex?
- Progaurd related questions?
- What is the context?
- What is the use of context?
- What is a context wrapper?
- How to efficiently use context?
- Memory leak due to misuse of context?
- Application context vs Activity context?
- What is an Adapter?
- Why we need an adapter?
- What is the layout inflater?
- What is a Cursor adapter?
- What are different types of the adapter and in which circumstances we should use each of them?
- What is the base adapter?
- What is the recycler view adapter?
- what is the list view or recycler view?
- What the difference between both of them?
- Methods of RV and LV?
- What are the method sequences to get called?
- Mandatory methods to implement in your subclass of adapter?
- How onItem click works on both of them?
- What is an item decorator in RV?
- What is the view holder?
- Multiple view type in Single recycler view?
- Multiple adapters in a single RV?
- How Memory efficient RV?
- Use of layoutmangar in RV?
- What is the shared preference?
- How data is stored in a shared preference?
- Can an app have multiple shared pref files?
- In which format data is stored in shared preference?
- What is the editor in shared pref?
- What are the modes of shared pref?
- Path of the shared pref file in a device where it is stored?
- Methods of shared prefs?
- Differences between commit and apply?
- What all the types of data we can store in shared pref?
- When the data will be deleted from the shared pref?
- What is a viewpager?
- Difference between fragmentPaggerAdapter and fragmentStatePaggerAdapter?
- What is a thread?
- What is the process?
- What is a handler?
- What is looper?
- What is the message queue?
- In which thread handler works?
- How to update UI from background thread?
- Which exception will come while updating UI from the background?
- What is looper.getMainLooper()?
- Methods of handler?
- Difference between post and send?
- What is a thread pool?
- What are the changes introduced in Lolipop?
- New features in Marshmellow?
- New features in Nougat?
- New features in Oreo?
- New features in Pie?
- New features in 10.
- What is the async task?
- How does it work?
- What all methods of the async task?
- Can you start the async task again?
- What happens to the async task when you change the orientation?
- How to prevent async task data on change orientation changes?
- Relationship between async task and activity?
- How to Update UI from doInBackground() method