Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What is JobScheduler?

Answer»

The JobSchedular API is used for scheduling different types of jobs against the framework that will be executed in your app’s own process. This allows your application to perform the given task while being considerate of the device’s battery at the cost of timing control.

The JobScheduler supports batch scheduling of jobs. The Android system can combine jobs for reducing battery consumption. JobManager automatically handles the network unreliability so it makes handling uploads easier.

Here is some example of the situation where you would use this job scheduler:

  • Tasks that should be done when the device is connected to a power supply.
  • Tasks that require a Wi-Fi connection or network access.
  • Tasks that should run on a regular BASIS as batch where the timing is not critical.
Conclusion

Android system gives a platform for a developer from which they can display the applications to the smartphone users and find potential customers out of them. It ALSO PROVIDES PAID and free applications for the users that could secure their DATA serves as a platform for information and gives various services as per the needs of the customers.

Useful Resources:
Android Developer Salary

2.

Explain about java classes related to the use of sensors on Android.

Answer»

Android sensor API provides many classes and interface for the use of sensors on Android. The important classes and interfaces of sensor API are given below:

  • Sensor class: This class helps you to CREATE an instance of a specific sensor. It provides methods that let you DETERMINE a sensor’s capabilities.
  • SensorManager class: This class is used to create an instance of the sensor service. It provides methods to access and list sensors, to register and unregister sensor listeners, etc.
  • SensorEvent class: This Java class is used to create a sensor EVENT object. It provides INFORMATION about the sensor event including raw sensor data, the accuracy of data, type of sensor, timestamp of event, etc.
  • SensorEventListener interface: This interface is used to create two callback methods that receive sensor event notifications when sensor value changes or when sensor accuracy changes. Those two methods are VOID onAccuracyChanged(Sensor sensor, int accuracy) which is called when sensor accuracy is changed and
    void onSensorChanged(SensorEvent event) which is called when sensor values are changed.
3.

What is the difference between compileSdkVersion and targetSdkVersion?

Answer»

compileSdkVersion:

  • The compileSdkVersion is the version of API the application is compiled against. You can use Android API features involved in that version of the API (as well as all previous versions).
  • For example, if you try and use API 15 features but set compileSdkVersion to 14, you will get a compilation error. If you set compileSdkVersion to 15 you can still run the app on an API 14 device as long as your app’s execution paths do not attempt to invoke any APIs specific to API 15.

targetSdkVersion:

  • The targetSdkVersion indicates that you have tested your app on (presumably up to and including) the version you specify. This is like a CERTIFICATION or sign-off you are giving the Android OS as a HINT to how it should handle your application in terms of OS features.
  • For example, setting the targetSdkVersion value to “11” or higher permits the SYSTEM to APPLY a new default theme (Holo) to the application when running on Android 3.0 or higher. It also disables screen compatibility mode when running on larger screens (because support for API level 11 implicitly supports larger screens).
4.

What is the significance of the .dex file?

Answer»

Android programs are compiled into a .dex file (Dalvik Executable file) by DVM, which are then zipped into a .apk file on the DEVICE. .dex files are CREATED by translating compiled applications written in java. .dex is a format that is optimized for EFFECTIVE storage and memory-mappable EXECUTIONS.

5.

What is the content provider? How it is implemented?

Answer»

Content provider is ONE of the primary BUILDING blocks of Android applications, which manages access to a central repository of data. It acts as a standard interface that connects data in one process with code running in another process. So it can be used to share the data between different applications.

They are responsible for encapsulating the data and providing mechanisms for defining data security. It is implemented as a subclass of ContentProviderclass and must implement a set of APIs that will ENABLE other applications to PERFORM transactions.

public class MyContentprovider extends CONTENTPROVIDER { public void onCreate(){}}
6.

What are the differences between Service and Thread?

Answer»

The main difference between Service and THREAD is given below:

ServiceThread
Service is an application COMPONENT that FACILITATES an application to run in the background in order to perform long-running operations without user interaction. A Thread is a concurrent unit of execution.
It exposes few functionalities to other applications by calling Context.bindService().GOOGLE has brought in HANDLERS and loopers into threads.
When an application is killed, service is not killed.When an application is killed, the thread is killed.
7.

What database is used in Android? How it is different from client-server database management systems?

Answer»

SQLite is the open-source RELATIONAL database used in ANDROID. The SQLite engine is serverless, transactional, and also self-contained. Instead of the client-server relationship of most database management systems, the SQLite engine is integrally LINKED with the APPLICATION. The library can be called dynamically and it can make use of simple function CALLS that reduce latency in database access.

8.

What is the difference between Serializable and Parcelable? Which is the best approach in Android?

Answer»

While developing applications usually it needs to transfer data from one ACTIVITY to another. This data needs to be added into a CORRESPONDING INTENT object. Some additional actions are required to make the data suitable for transfer. For doing that the object should be either serializable or parcelable.

Serializable:

  • Serializable is a standard Java interface. In this approach, you simply mark a class Serializable by implementing the interface and java will automatically serialize it.
  • Reflection is used during the PROCESS and many additional objects are created. This leads to plenty of garbage collection and poor performance.

Parcelable:

  • Parcelable is an Android-specific interface. In this approach, you implement the serialization yourself.
  • Reflection is not used during this process and hence no garbage is created.
  • Parcelable is far more efficient than Serializable since it GETS around some problems with the default Java serialization scheme. Also, it is faster because it is optimized for usage on the development of Android, and shows better results.
9.

Explain in detail about the important file and folders used when you create a new Android application.

Answer»

App:

It DESCRIBES the basic characteristics of the application and defines each of its components.

java:

  • This contains the .java source files and .kt(source code written in Kotlin) source files of your project. By default, it includes a MainActivity.java or MainActivity.kt source file.
  • You create all the activities which have .java and .kt extensions under this file and also it includes all the code behind the application.

res:

  • It is used to store the values for the RESOURCES that are used in VARIOUS Android projects to include features of color, styles, dimensions, etc.
  • It is a directory for files LIKE styles.xml, strings.xml, colors.xml, dimens.xml, etc.

Scripts:

This is an auto-generated file that consists of compileSdkVersion, buildToolsVersion, minSdkVersion, targetSdkVersion, applicationId, versionCode, and versionName. For example, build.gradle is a script file placed in the root project directory, defines build configurations that will be APPLIED to all modules in your project.

10.

What are broadcast receivers? How is it implemented?

Answer»

A broadcast receiver is a mechanism USED for LISTENING to system-level events like listening for incoming calls, SMS, etc. by the HOST APPLICATION. It is implemented as a subclass of BroadcastReceiver CLASS and each message is broadcasted as an intent object.

public class MyReceiver extends BroadcastReceiver { public void onReceive(context,intent){}}