Most asked Android Interview Questions

To crack an Android interview is a challenging task itself, As there are lots of concepts in Android which every Android developer must know. So here is the List of the top Most asked Android Interview questions. I also have listed kotlin interview questions as well. These questions have been asked in OLA, Sharechat, TekionCork, KooApp etc.

Questions Related to Android 

 1. Activity LifeCycle

Activity lifecycle

2. Lifecycle of Views

view Lifecycle

3. Android scenario where ondestroy() is called without onpause() or onstop()

Ans: This happens when we call the finish() method in oncreate of activity.

4. List of Android Scnerios that are most commonly asked.

What happens?When

open the app::  onCreate() –> onStart() –> onResume()
When back button pressed and exit the app::  onPaused() — > onStop() –> onDestory()
When home button pressed::  onPaused() –> onStop()
After pressed home button when again open app from recent task list or clicked on icon ::  onRestart() –> onStart() –> onResume()
When open app another app from notification bar or open settings::  onPaused() –> onStop()
Back button pressed from another app or settings then used can see our app::  onRestart() –> onStart() –> onResume()
When any dialog open on screen::  onPause()
After dismiss the dialog or back button from dialog::  onResume()
Any phone is ringing and user in the app::  onPause() –> onResume()
When user pressed phone’s answer button::  onPause()
After call end::  onResume()
When phone screen off::  onPaused() –> onStop()
When screen is turned back on::  onRestart() –> onStart() –> onResume()

5. What is Diff between onCreate() and onStart()

Ans: The onCreate() method is called once during the Activity lifecycle, either when the application starts, or when the Activity has been destroyed and then recreated, for example during a configuration change.
The onStart() method is called whenever the Activity becomes visible to the user, typically after onCreate() or onRestart().

6. Why do we set content view in onCreate() and not in onStart() ?

As onCreate() of an Activity is called only once, this is the point where most initialization should go: calling setContentView(int) to inflate the activity’s UI, using findViewById to programmatically interact with widgets in the UI. You don’t setContentView in onStart or onResume because it’s inefficient. Setting up the layout is a pretty heavyweight task. You have to parse the XML, create the Views, measurements, drawing, etc. It’s the sort of task that you want to run at most once.

During the lifetime of your Activity class onCreate gets called exactly once. onResume and onStart will get called multiple times without your Activity getting destroyed.

7. How does the activity respond when the user rotates the screen?

When the screen is rotated, the current instance of activity is destroyed a new instance of the Activity is created in the new orientation. The onRestart() method is invoked first when a screen is rotated. The other lifecycle methods get invoked in the similar flow as they were when the activity was first created.

8. What are Android development components

There are four different types of app components:

  • Activities
  • Services
  • Broadcast receivers
  • Content providers

For more info read this click here 

Note: Answer of All Questions will be post in one or two days

9. What are Launch modes of Activity

There are four launch modes for activity.

  1. standard
  2. singleTop
  3. singleTask
  4. singleInstance   

click here to understand launch modes in detail

10. What is Fragment and its Lifecycle

Fragment class in Android is used to build dynamic User Interfaces. It is light weight as compare to activity and in order to make an app lightweight, we must use maximum fragments and minimum Activities.  It should be used within the Activity. A greatest advantage of fragments is that it simplify the task of creating UI for multiple screen sizes. An activity can contain any number of fragments.

fragment lifecycle

Activity State Fragment Callbacks Triggered Fragment Lifecycle
Created onAttach(), onCreate(), onCreateView(), onActivityCreated() Fragment is added and its layout is inflated.
Started onStart() Fragment is active and visible.
Resumed onResume() Fragment is active and ready for user interaction.
Paused onPause() Fragment is paused because the Activity is paused.
Stoped onStop() Fragment is stopped and no longer visible.
Destroyed onDestroyView(), onDestroy(), onDetach()

Fragment is destroyed.

11. Use of Fragments.

Fragments are more of a UI benefit. It’s convenient for the user sometimes to see two different views of two different classes on the same screen. If, in your moment of creativity, you decide it would be nice to display your application with, say, a listView that takes up half the screen and a webView that takes up the other half – so that when you click on a list item in fragment A it passes an intent to the webView in fragment B, and suddenly you see what you just clicked without the app switching activities – then you could use a fragment.  (source StackOverflow)

  1. When should you use a fragment rather than an activity?
  2. Locks and semaphores
  3. Why use constraint layout
  4. What are Services { foreground, background, bound}
  5. What is Broadcast receiver
  6. What is Content provider
  7. What is Intents and its types. (Explicit and Implicit)
  8. How to communicate between fragments?
  9. What are Handlers?
  10. Difference between Activity & Service
  11. What is an Application Not Responding (ANR) error, and how can you prevent them from occurring in an app?
  12. Recyclerview vs Listview
  13. Diff util in recyclerview
  14. Context vs application context vs requireContext vs getActivity
  15. File vs SQLite vs room DB
  16. Explain MVVM
  17. Why do we use ViewModel?
  18. What is LiveData?
  19. Difference between LiveData and MutableLiveData.
  20. MVVM vs MVP vs MVC.
  21. Understanding of Clean code Architecture
  22. What is Dependency Injection?
  23. How to write unit testcase in android?
  24. Workmanager
  25. Navigation component and graph
  26. Firebase related basic knowledge.

Kotlin Interview Questions

  1. Why kotlin is better than java?
  2. var vs val
  3. Lateinit vs lazy
  4. What is Null safety and where we use elvish operator (?:)
  5. Scope function (apply, with, let, also, run)
  6. What is the Extension function? and use of Extension function
  7. What are Coroutines?
  8. Diff between launch and async
  9. What are Threads.
  10. Coroutines vs threads
  11. What is data class in kotlin?
  12. How data class is different from java POJO class
  13. Openclass
  14. Sealed class
  15. Put vs post vs patch
  16. 401 vs 403
  17. Higher-order functions
  18. Serialisable vs Parceleble
  19. String buffer string builder
  20. Diff between == and === in kotlin and java
  21. Bundle vs hashmap

So these are the questions that have been asked in many interviews of Good MNCs and product-based startups (OLA, Sharechat, TekionCork, KooApp).

Note: If you know some questions which are not listed there, feel free to comment so that we can add in this list. My ultimate goal is to make this article the best source to prepare for an Android interview.

About me

I am a Software development Engineer -1 (Android) at ShareChat. Also has been working with Nagarro. 🏆 Got Ist position in “Build For Bharat🇮🇳” Android Hackathon | ▶️ 3k+ subscriber on Youtube | Came from < Tier 3

To know more about me connect with me on Linkedin

Connect

Leave a Comment

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