Interview answers verified by specialists.
Find interview questions and answers on this website:
There are several types of approaches that are required to share the objects and all of them are listed below: - Singleton class: is used for the application components that run in the same process. This allows the design to run only one instance at a time. It includes static methods with a name like getInstance(). This method returns the instance whenever it is called for the first time. This method also creates a global instance so that it can be called easily without using more memory in creation and destroying of the process. - A public static field or method: is used as an alternate method to make the data accessible across Activities and Services that is to be used by the public. This defines the static fields or methods that are used by other classes in the application. The method is used to share an object that gets created by the static field pointing to an object and other accessible fields. - A HashMap of WeakReferences to Objects: provide some long keys that map the activities that is called by an object from another object. This after mapping sends a key that is unique and long to show the truthfulness of the object.