Android Interview Questions(CH#2)
Let’s bring it on the second chapter of our Android Interview Questions series where we discover the most asked questions in an Android Interview anywhere in the world.
1) What is the importance of XML-based layouts?
The use of XML-based layouts provides a consistent and somewhat standard means of setting GUI definition format. In common practice, layout details are placed in XML files while other items are placed in source files.
2) What are the containers?
Containers, as the name itself implies, holds objects and widgets together, depending on which specific items are needed and in what particular arrangement that is wanted. Containers may hold labels, fields, buttons, or even child containers, as examples.
3) What is the importance of Android in the mobile market?
Developers can write and register apps that will specifically run under the Android environment. This means that every mobile device that is Android enabled will be able to support and run these apps. With the growing popularity of Android mobile devices, developers can take advantage of this trend by creating and uploading their apps on the Android Market for distribution to anyone who wants to download it.
4) What do you think are some disadvantages of Android?
Given that Android is an open-source platform and the fact that different Android operating systems have been released on different mobile devices, there’s no clear-cut policy to how applications can adapt with various OS versions and upgrades. One app that runs on this particular version of Android OS may or may not run on another version. Another disadvantage is that since mobile devices such as phones and tabs come in different sizes and forms, it poses a challenge for developers to create apps that can adjust correctly to the right screen size and other varying features and specs.
5) What are the four essential states of an activity?
– Active — if the activity is at the foreground
– Paused — if the activity is at the background and still visible
– Stopped — if the activity is not visible and therefore is hidden or obscured by another activity
– Destroyed — when the activity process is killed or completed terminated
6) What is ANR?
ANR is short for Application Not Responding. This is a dialog that appears to the user whenever an application has been unresponsive for an extended period.
7) What is the importance of settings permissions in app development?
Permissions allow certain restrictions to be imposed primarily to protect data and code. Without these, codes could be compromised, resulting in defects in functionality.
8) What is the function of an intent filter?
Because every component needs to indicate which intents they can respond to, intent filters are used to filter out intents that these components are willing to receive. One or more intent filters are possible, depending on the services and activities that are going to make use of it.
9) How can the ANR be prevented?
One technique that prevents the Android system from concluding a code that has been responsible for an extended period is to create a child thread. Within the child thread, most of the actual workings of the codes can be placed, so that the main thread runs with minimal periods of unresponsive times.
10) What role does Dalvik play in Android development?
Dalvik serves as a virtual machine, and it is where every Android application runs. Through Dalvik, a device can execute multiple virtual machines efficiently through better memory management.
11) Enumerate the steps in creating a bounded service through AIDL.
1. create the .aidl file, which defines the programming interface
2. implement the interface, which involves extending the inner abstract Stub class as well as implanting its methods.
3. expose the interface, which involves implementing the service to the clients.
12) What is the importance of Default Resources?
When default resources, which contain default strings and files, are not present, an error will occur and the app will not run. Resources are placed in specially named sub-directories under the project res/ directory.
13) When is the best time to kill a foreground activity?
The foreground activity, being the most important among the other states, is only killed or terminated as a last resort, especially if it is already consuming too much memory. When a foreground activity has reached a memory paging state, then it is killed so that the user interface can retain its responsiveness to the user.
14) Is it possible to use or add a fragment without using a user interface?
Yes, it is possible to do that, such as when you want to create a background behavior for a particular activity. You can do this by using add(Fragment, string) method to add a fragment from the activity.
15) What is a portable Wi-Fi Hotspot?
Portable Wi-Fi Hotspot allows you to share your mobile internet connection to other wireless devices. For example, using your Android-powered phone as a Wi-Fi Hotspot, you can use your laptop to connect to the Internet using that access point.
16) What is an action?
In Android development, an action is what the intent sender wants to do or expected to get as a response. Most application functionality is based on the intended action.
17) What is a Sticky Intent?
sendStickyBroadcast() performs a sendBroadcast(Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete so that others can quickly retrieve that data through the return value of registerReceiver(BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent). One example of a sticky broadcast sent via the operating system is ACTION_BATTERY_CHANGED. When you call registerReceiver() for that action — even with a null BroadcastReceiver — you get the Intent that was the last broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery.
18) What is the difference between a regular .png and a nine-patch image?
This is one of the most popular Android Interview questions, asked in several interviews ranging from 1 to 2 years of experience to 5 years. The answer is, It is a re-sizable bitmap resource that can be used for backgrounds or other images on the device. The NinePatch class permits drawing a bitmap in nine sections. The nine patch images have an extension as .9.png. It allows extension in 9 ways e.g. 4 corners that are unscaled, 4 edges that are scaled in 1 axis, and the middle one that can be scaled into both axes.
19) What is Setting Breakpoints?
Breakpoints are a mechanism by which you can tell Android Studio to temporarily pause execution of your code.
20) What is dp, sp, pt, and px?
dp — Density: -independent pixel. 1 dp is equivalent to one pixel on a 160 dpi screen. This is the recommended unit of measurement when you’re specifying the dimension of views in your layout.
sp — Scale:- independent pixel. This is similar to dp and is recommended for specifying font sizes.
pt — Point:- A point is defined to be 1/72 of an inch, based on the physical screen size.
px — Pixel:- Corresponds to actual pixels on the screen. Using this unit is not recommended, as your UI might not render correctly on devices with a different screen resolution.
Note: Stay Tuned for CH#3 of this series for more questions like this.
Kudos To Every Android Buddy…