Pages

getteammates.com

Saturday, 5 March 2016

Advanced Android Interview Questions and Answers 1

  1. Advanced Android Interview Questions and Answers 1 
  2. Advanced Android Interview Questions and Answers 2
  3. Advanced Android Interview Questions and Answers 3
  4. Advanced Android Interview Questions and Answers 4


1. What is the architecture of Android?


2. How many ways are there to create a bound service?

SHOW/HIDE ANSWER
Three,
  • Extending the Binder class
  • Using a Messenger
  • Using AIDL

3. What are the steps to create a Bound service using AIDL?

SHOW/HIDE ANSWER
Three,
  • Create the .aidl file : defines the programming interface with method signatures
  • Implement the interface : extend the Stub class and implement the methods
  • Expose the interface to clients : Implement a Service and override onBind() to return your implementation of the Stub class

4. Will calling finish() on an Activity calls all the usual activity life cycle method?

SHOW/HIDE ANSWER
Yes, except if you are calling it from onCreate, in which case onDestroy() will be immediately called without any of the rest of the activity lifecycle (onStart(), onResume(), onPause(), etc) executing.

5. Should base Activity class's onCreate should be called from your Activity implementation?

SHOW/HIDE ANSWER
Yes, if not an exception will be thrown.

6. What is the activity life cycle?

SHOW/HIDE ANSWER
  • onCreate : System calls this method while creating the activity
  • onStart : Called just before the activity becomes visible
  • onResume : Called just before the activity starts interacting with the user, such as receiving the events
  • onPause : Called when the system is about to start resuming another activity
  • onStop : Called when the activity is no longer visible to the user
  • onRestart : Called after the activity has been stopped, just prior to it being started again
  • onDestroy : Called before the activity is destroyed
Reference
http://developer.android.com/guide/components/activities.html

7. What is the Fragment life cycle?

SHOW/HIDE ANSWER
  • onAttach: called once the fragment is associated with its activity.
  • onCreate: called to do initial creation of the fragment.
  • onCreateView: creates and returns the view hierarchy associated with the fragment.
  • onActivityCreated: tells the fragment that its activity has completed its own Activity.onCreate().
  • onViewStateRestored: tells the fragment that all of the saved state of its view hierarchy has been restored.
  • onStart: makes the fragment visible to the user (based on its containing activity being started).
  • onResume: makes the fragment begin interacting with the user (based on its containing activity being resumed).
  • onPause: fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity.
  • onStop: fragment is no longer visible to the user either because its activity is being stopped or a fragment operation is modifying it in the activity.
  • onDestroyView: allows the fragment to clean up resources associated with its View.
  • onDestroy: called to do final cleanup of the fragment's state.
  • onDetach: called immediately prior to the fragment no longer being associated with its activity.

Reference
http://developer.android.com/guide/components/fragments.html
http://developer.android.com/reference/android/app/Fragment.html

8. How to programmatically add fragment to an existing ViewGroup?

SHOW/HIDE ANSWER
// Create new fragment and transaction
Fragment newFragment = new ExampleFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();

// Replace whatever is in the fragment_container view with this fragment,
// and add the transaction to the back stack
transaction.replace(R.id.fragment_container, newFragment);
transaction.addToBackStack(null);

// Commit the transaction
transaction.commit();

Reference
http://developer.android.com/guide/components/fragments.html#Adding

9. What are the steps to implement Loader?

SHOW/HIDE ANSWER
  • Initialize the LoadManager or restart it with initLoader or restartLoader respectively
  • Implement the Loader implementation class
  • Override the LoaderManager.LoaderCallbacks
  • Return your Loader implementation from onCreateLoader
  • Use the data from onLoadFinished
Reference
http://developer.android.com/guide/components/loaders.html

10. What are the two types on Intents?

SHOW/HIDE ANSWER
  • Explicit intents specify the component to start by name (the fully-qualified class name)
  • Implicit intents do not name a specific component, but instead declare a general action to perform, which allows a component from another app to handle it.
Reference
http://developer.android.com/guide/components/intents-filters.html#Types

11. What is a content provider?

SHOW/HIDE ANSWER
Content provider can be used to share data between or within applications.

12. What are the advantages of AsyncTaskLoader over AsyncTask?

SHOW/HIDE ANSWER
  • AsyncTaskLoader can an handle Activity configuration changes more easily
  • Closer relationship with Activity/Fragment life-cycle

13. How many threads are there to service AsyncTask jobs?


14. What are the levels in the importance hierarchy for an Android process?

SHOW/HIDE ANSWER
There are 5 of them and they are,
  • Foreground process
  • Visible process
  • Service process
  • Background process
  • Empty process
Reference
http://developer.android.com/guide/components/processes-and-threads.html#Lifecycle

15. What is reactive programming?

SHOW/HIDE ANSWER
It is an emerging discipline that combines asynchronous and event-based systems. RxAndroid provides support for reactive programming for Android.
References
https://github.com/ReactiveX/RxAndroid
http://reactivex.io/tutorials.html
https://www.youtube.com/watch?v=JCLZ55M2gVo

16. How to cancel an AsyncTask?

SHOW/HIDE ANSWER
First call the method cancel on the AsyncTask. Now it will not cause the AsyncTask to cancel by interrupting the background thread. But it will cause isCancelled() to return true. You should always check the return value of isCancelled() periodically from doInBackground(Object[]), if possible (inside a loop for instance.) Reference
http://developer.android.com/reference/android/os/AsyncTask.html

17. What are the two types of services?

SHOW/HIDE ANSWER
  • Started : If is started by calling startService().
  • Bounded : If is started by calling bindService().
Reference
http://developer.android.com/guide/components/services.html

18. In which thread does a Started or Bounded service run?

SHOW/HIDE ANSWER
Main thread

19. Can a service run in the foreground?


20. What is Retrolambda?


2 comments:

  1. Tks very much for your post.

    Avoid surprises — interviews need preparation. Some questions come up time and time again — usually about you, your experience and the job itself. We've gathered together the most common questions so you can get your preparation off to a flying start.

    You also find all interview questions at link at the end of this post.

    Source: Download Ebook: Ultimate Guide To Job Interview Questions Answers:

    Best rgs

    ReplyDelete