/** * Functions hooked into colormag_action_head action. * * @hooked colormag_head - 10 */ do_action( 'colormag_action_head' ); wp_head(); ?>

Top 10 Latest android interview questions and answers

1.What do you mean by Android AsyncTask(Asynchronous task) ?

An asynchronous task is used to perform an operation into the background thread and update the main thread after completing the process or result.

Example:

When we download any content from the website or internet then we see the downloading operations are performed into the background.

After completing the process or download,we see the result on the main thread.

# Methods of Asynchronous task

1.onPreExecute( ) 2.doInBackground( ) 3.onProgressUpdate( ) 4.onPostExecute()

#There are three generic parameters used in AsyncTask.

1.Params 2.Progress 3.Result

2.What is the difference between add( ) and replace( ) method in fragments ?

add( ):  is used to retain existing fragment and adds new fragment that means existing fragment will be in active state and it won’t be in ‘pause’ state hence when a back button is pressed onCreateView( ) will be not called for the existing fragment(previous fragment). 


replace( ): is used to replace the existing fragment and adds a new fragment.That means when we press back button the fragment gets replaced and onCreateView( ) method will be called.

3.What do by means of View Model and Live Data  ?

View Model:

View Model class is used to store and manage UI(User Interface) related data in a an android life-cycle

It is also used to survive the data on configuration change such as screen rotation.

Live Data:

Live Data is an observable data holder class.It notify the observer when any updates are made on the UI(User Interface).

There are the different advantages of Live Data

1.It ensures your UI matches your data state

2.No Memory leaks

3.No crashes due to stopped activities

4.Always up to date data

4.How many  types of Launch mode in an android ?

There are four types of launch mode in an android

1.Standard

2.SingleTask

3.SingleTop

4.SingleInstance

5.What do you mean by Activity and Application Context ?

Activity context:

Activity context refers to the instance of the activity within the activity -lifecycle.

Application context:

Activity context refers to the instance of the activity within the application -life-cycle.

6.What do you mean by DVM(Dalvik virtual machine) ?

Android uses DVM(Dalvik virtual machine) rather than JVM.All the java classes are converted into single. dex file by Dex compiler and this .dex file runs on the Dalvik virtual machine.

7.Suppose you have two activities A and B.When you move from activity A to B.Which activity -life method will be called ?

## When launch activity  A

-onCreate( )

-onStart( )

-onResume( )

## When Move from activity A to B by using startActivity(intent)

Activity A -onPause( )

Activity B- onCreate( )

                   onStart( )

                 onResume( )

Activity A-onStop( )

## When you press back button from activity B then activity-lifecycle method will be called

Activity B-onPause( )

Activity A -onRestart( )

                  onStart( )

                  onResume( )

Activity B- onStop( )

                  onDestroy( )

8.Write down Activity-Lifecycle and Fragment Life-cycle ?

Activity-LifeCycle

-onCreate( )

-onStart( )

-onResume( )

-onPause( )

-onStop( )

-onRestart( )

-onDestroy( )

Fragment-LifeCycle

-onAttach( )

-onCreate( )

-onCreateView( )

-onActivityCreated( )

-onStart( )

-onResume( )

-onPause( )

-onStop( )

-onDestroyView( )

-onDestroy( )

-onDetach( )

9.How can you data from Activity to Fragment using a bundle ?

Activity class

##Write below code inside the button click listener

Bundle b=new Bundle( );

b.putString(“name”,”suman kumar”);

FragmentName fragment=new FragmentName( );

fragment.setArguments(b);

Fragment class

##Write the below code inside the onCreateView( ) method.

String name=getArguments.getString(“name”);

10.What do you mean by Services in an android ?

Service is an android component which runs into the background to perform long-running operation.It does not contain any UI(User Interface )

There are three types of services is an android

1.Foreground Service

2.Background Service

3.Bound Service

Thanks and Regards

Placement preparation

sumankumar80

Hello Friends,I have written and developed this website because you can learn technology easily ,prepare for the placement and also for the any type of examination . By :Suman Kumar

Leave a Reply

Your email address will not be published. Required fields are marked *