Skip to content
tezvyn:

Top 30 Lifecycle Interview Questions and Answers

30 multiple-choice questions on Lifecycle, drawn from 30 bites out of the 49 tagged Lifecycle on Tezvyn. Answer them here or read straight down. Every question carries the correct option, why it is correct, and a link to the bite it came from.

30 questions. Pick an answer, or open “Show the answer” to read it.

Answers are graded in your browser. Nothing is saved, and no XP or streak is earned here. The app keeps score.

  1. Question 1 of 30

    An Android Fragment needs a property for a complex, computationally expensive object that is only used in certain user flows. The object should be created only once. Which declaration is most appropriate?

    Show the answer

    Answer: b · private val myObject: MyObject by lazy { createExpensiveObject() }

    `val by lazy` is ideal for expensive, immutable properties because it defers creation until first access and caches the result. `lateinit var` is incorrect because the property is immutable and is meant for when an external framework provides the value, not for deferred computation.

    Read the full bite: lateinit var vs. val by lazy in Android

  2. Question 2 of 30

    Which statement accurately describes a fundamental difference between lateinit var and val by lazy in Kotlin?

    Show the answer

    Answer: b · val by lazy can initialize properties of any type, including primitives, unlike lateinit var.

    The card states that lateinit var cannot be used for primitive types like Int or Boolean, while val by lazy has no such restriction. Option A is incorrect because it describes the behavior of val by lazy, not lateinit var, which is initialized manually.

    Read the full bite: lateinit var vs. val by lazy in Android

  3. Question 3 of 30

    What is the practical difference between onStartShouldSetResponder and onMoveShouldSetResponder?

    Show the answer

    Answer: d · Start claims the touch immediately on contact, while Move lets a view claim it only after the finger moves, distinguishing taps from drags

    onStartShouldSetResponder negotiates ownership at touch down, while onMoveShouldSetResponder lets a view wait and claim the gesture once movement begins, which is how a drag is separated from a tap. They are not aliases and Move does not precede Start.

    Read the full bite: Gesture Responder System lifecycle

  4. Question 4 of 30

    Which approach correctly places a one-time network request and a bounds-dependent layout update in a UIViewController?

    Show the answer

    Answer: d · Start the request in viewDidLoad and update frames in viewDidLayoutSubviews

    viewDidLoad runs once after the view is created, making it the right place for an initial network request, while viewDidLayoutSubviews fires after Auto Layout resolves final bounds so frames are accurate there. Updating frames in viewDidLoad is a common mistake because safe area insets and final bounds are not yet guaranteed at that point.

    Read the full bite: UIViewController lifecycle states: network vs geometry updates

  5. Question 5 of 30

    What is the effect of calling setState inside didUpdateWidget when reacting to a parent configuration change?

    Show the answer

    Answer: b · It schedules a second build, making the call redundant

    Flutter guarantees that build follows didUpdateWidget, so setState inside it merely queues an extra unnecessary frame. The suppressing-build option is wrong because the framework-triggered build is never canceled by a nested setState call.

    Read the full bite: Explain the lifecycle of a State object

  6. Question 6 of 30

    When an Android Activity becomes completely invisible because the user navigated away, which lifecycle method is the most appropriate place to release expensive resources like a camera or network connection?

    Show the answer

    Answer: d · onStop()

    onStop() is the correct method because it is called when the Activity is no longer visible, making it suitable for releasing expensive resources. onPause() is incorrect as it must execute very quickly and is for pausing lightweight operations when the Activity is only partially obscured.

    Read the full bite: Describe the Android Activity lifecycle when navigating away and back

  7. Question 7 of 30

    Where should a scene-based iOS app save important user state to avoid data loss, and why?

    Show the answer

    Answer: d · In sceneDidEnterBackground, because termination from a suspended state may never call a termination method

    A suspended app can be killed without applicationWillTerminate ever being called, so saving in sceneDidEnterBackground guarantees state is persisted while code can still run. Relying on termination callbacks risks silent data loss.

    Read the full bite: Describe the iOS app lifecycle and SceneDelegate methods

  8. Question 8 of 30

    When a user navigates away from an Activity, why is it better to release a resource-intensive object like a camera in onStop() instead of onPause()?

    Show the answer

    Answer: d · onPause() execution must be very fast because it blocks the next Activity from appearing.

    Correct. onPause() must be lightweight because it blocks the UI thread and can delay the next Activity from appearing. Heavy cleanup belongs in onStop() since the Activity is already hidden from the user.

    Read the full bite: Trace an Activity's lifecycle when a user navigates away and returns

  9. Question 9 of 30

    What is the primary distinction in lifecycle management between an Android Started Service and a Bound Service?

    Show the answer

    Answer: a · A Started Service runs independently and must call stopSelf() to terminate, while a Bound Service's lifecycle is governed by its bound clients.

    A Started Service runs independently of its calling component and must explicitly stop itself using stopSelf(), whereas a Bound Service's lifecycle is directly tied to its bound clients, being destroyed when the last client unbinds. Option C is incorrect because a Started Service continues running even if its starter is destroyed.

    Read the full bite: Started vs. Bound Services: Differences and Use Cases

  10. Question 10 of 30

    When using a Started Service for a long-running task like a file download, what is the most critical step to ensure the app's UI remains responsive?

    Show the answer

    Answer: b · Move the download logic to a background thread created within the service.

    Services run on the application's main thread by default. To prevent the UI from freezing, any long-running operation must be explicitly moved to a separate worker thread. While starting it as a foreground service (D) is common for long tasks, it doesn't solve the main thread blocking issue.

    Read the full bite: Started vs. Bound Services: Differences and Use Cases

  11. Question 11 of 30

    In an iOS 13+ app using scenes, which task is appropriately handled by SceneDelegate rather than AppDelegate?

    Show the answer

    Answer: c · Restoring user interface state for a specific window session

    SceneDelegate owns per-window state restoration and UI lifecycle, whereas AppDelegate manages process-wide singletons and events. Option B is tempting because it occurs in the background, but silent pushes are process-level and must be handled by AppDelegate.

    Read the full bite: How do AppDelegate and SceneDelegate responsibilities differ?

  12. Question 12 of 30

    Which statement accurately contrasts a started service with a bound service in Android?

    Show the answer

    Answer: c · A started service runs indefinitely until stopSelf or stopService is called, while a bound service is destroyed once all clients unbind.

    A started service runs independently until explicitly stopped, while a bound service is destroyed automatically when no clients remain bound. Distractor A is wrong because started services do not stop simply because the starting component is destroyed, and bound services do not persist after all clients unbind.

    Read the full bite: What is the difference between a started service and a bound service?

  13. Question 13 of 30

    When an Activity is recreated after a screen rotation, what is the primary mechanism that allows it to retrieve the exact same ViewModel instance?

    Show the answer

    Answer: a · The new Activity instance connects to a retained ViewModelStore that holds the original ViewModel.

    The ViewModel is retained in a ViewModelStore object, which is not destroyed during configuration changes. The new Activity instance connects to this same store to retrieve the existing ViewModel. `onSaveInstanceState` is for smaller data and also handles process death, which ViewModels do not.

    Read the full bite: How does a ViewModel survive configuration changes?

  14. Question 14 of 30

    When an Activity is destroyed during a screen rotation, why does its associated ViewModel remain available to the new Activity instance?

    Show the answer

    Answer: b · The framework retains the ViewModelStore and reattaches it to the new Activity instance.

    The framework retains the ViewModelStore across configuration changes and reattaches it to the new Activity instance, so the same ViewModel object is reused. The most tempting distractor, onSaveInstanceState, only persists small parcelable data in a Bundle and cannot restore live objects like a ViewModel.

    Read the full bite: How does a ViewModel survive configuration changes and what is its scope?

  15. Question 15 of 30

    Which statement accurately describes how an Android ViewModel maintains its state during configuration changes, such as screen rotation?

    Show the answer

    Answer: d · The ViewModel is associated with a ViewModelStore that is retained across configuration changes, allowing the new ViewModelStoreOwner instance to retrieve the same ViewModel.

    The correct answer is C because a ViewModel is scoped to a ViewModelStoreOwner, and its ViewModelStore is retained across configuration changes, enabling the new UI controller to retrieve the existing ViewModel instance. Option B is incorrect as onSaveInstanceState() is for serializing small data to a Bundle to survive process death, not for retaining complex ViewModel objects in memory across configuration changes.

    Read the full bite: How does a ViewModel survive configuration changes?

  16. Question 16 of 30

    Which statement accurately describes a key difference between static and dynamic BroadcastReceiver registration on Android 8.0+ (API 26)?

    Show the answer

    Answer: b · Static receivers survive app death but are blocked from most implicit broadcasts unless exempted, while dynamic receivers tied to a context can receive implicit broadcasts but must be unregistered.

    This is correct because API 26 restricts most implicit broadcasts from reaching manifest-registered receivers unless exempted (e.g., BOOT_COMPLETED), whereas dynamic receivers can still receive implicit broadcasts while their context is alive but must be unregistered to prevent leaks. Option A is tempting but wrong because it ignores the API 26 restriction that blocks most implicit broadcasts from static receivers.

    Read the full bite: Static vs dynamic BroadcastReceiver registration and modern Android implications

  17. Question 17 of 30

    Which scenario best describes the appropriate use of an Android Activity?

    Show the answer

    Answer: c · Representing a distinct, full-screen user interface, like a login page or a settings screen.

    An Activity is designed to represent a single, distinct screen or a major entry point in an application, as described in the card. Displaying minor UI changes (option A) is explicitly mentioned as a scenario where an Activity should not be used, while options B and D describe the roles of other Android components like Services or Fragments/Views.

    Read the full bite: Android Activity: A Single Screen in Your App

  18. Question 18 of 30

    When an Android app recovers from process death, what is the key difference in state restoration compared to a configuration change, and what is the recommended solution?

    Show the answer

    Answer: b · Process death destroys the entire application process, including standard ViewModels, making SavedStateHandle essential for transient UI state restoration.

    Process death recreates the entire process, destroying standard ViewModels, which is why SavedStateHandle is needed to persist transient UI state. In contrast, configuration changes preserve the process and existing ViewModel instances. Option D is incorrect because standard ViewModels do not survive process death.

    Read the full bite: Handle Android Process Death vs. Configuration Changes

  19. Question 19 of 30

    After an app's process is killed by the OS and the user navigates back, which statement accurately describes the state restoration process?

    Show the answer

    Answer: a · A new process, Activity, and ViewModel are created; the ViewModel restores its state from the SavedStateHandle.

    Process death destroys the entire process, so a new process, Activity, and ViewModel are all created. The ViewModel restores its state from the SavedStateHandle. A common error is confusing this with a configuration change, where the ViewModel instance does survive.

    Read the full bite: Explain app restoration after Android process death

  20. Question 20 of 30

    A bound service has two active Activity clients. If one client undergoes a configuration change, what happens to the service?

    Show the answer

    Answer: a · The service remains active; the changing client unbinds and re-binds, but onCreate() is not called.

    With multiple clients, a bound service is not destroyed until the last client unbinds. Therefore, when one client unbinds due to a config change, the service remains active. The new client instance re-binds, but since the service is already running, its onCreate() method is not called again. Option B is incorrect because onRebind() is called only if all clients had previously unbound and onUnbind() returned true.

    Read the full bite: Bound Service Lifecycle: Config Changes and Multiple Clients

  21. Question 21 of 30

    Why should initialization logic that reads @Input values be placed in ngOnInit instead of the constructor?

    Show the answer

    Answer: c · Because input properties are guaranteed to have their initial bound values in ngOnInit but not in the constructor.

    Angular initializes input bindings after class instantiation, so @Input values are undefined in the constructor but available in ngOnInit. Distractor A is wrong because constructors are still the correct place for dependency injection assignments, even if heavy setup logic should be avoided.

    Read the full bite: What is ngOnInit's purpose and why prefer it over the constructor?

  22. Question 22 of 30

    Two distinct clients are bound to a Service using BIND_AUTO_CREATE. If one client calls unbindService(), what is the immediate impact on the Service?

    Show the answer

    Answer: a · The Service continues to run because at least one client remains bound to it.

    The system maintains a reference count for bound services. onDestroy() is only called when the count drops to zero. Option B is a common misconception; onDestroy() is not called until the *last* client unbinds.

    Read the full bite: Bound Service Lifecycle with Config Changes & Multiple Clients

  23. Question 23 of 30

    What is the primary reason Android employs an Activity Lifecycle?

    Show the answer

    Answer: d · To provide a predictable mechanism for apps to manage resources and state during system-level interruptions.

    The Activity Lifecycle exists to provide a predictable contract for apps to manage their state and resources, especially when the OS needs to reclaim memory by terminating background apps. Option D directly reflects this purpose. Option A is incorrect because the OS can and does terminate background applications; the lifecycle helps apps gracefully handle this.

    Read the full bite: Android's Activity Lifecycle: A Screen's Journey

  24. Question 24 of 30

    An Activity binds to a service using BIND_AUTO_CREATE without startService. What happens to the service when the Activity is destroyed during rotation?

    Show the answer

    Answer: c · The service is destroyed if it has no other bound clients, and the new Activity must bind again

    The binding is torn down when the Activity is destroyed during rotation, so the service is destroyed if it has no other clients or started state, and the new Activity must rebind. Option B is a common misconception because BIND_AUTO_CREATE does not persist or migrate connections across config changes.

    Read the full bite: What happens to a bound service during config changes and multiple clients?

  25. Question 25 of 30

    To execute code every time a React Native screen becomes visible after being navigated away from, which method is most appropriate?

    Show the answer

    Answer: d · Subscribing to the 'focus' event using navigation.addListener

    The card states that screens remain mounted when navigated away from, so a standard useEffect with an empty dependency array (C) only runs on initial mount, not subsequent visibility changes. Subscribing to the 'focus' event (D) is the correct way to run code specifically when a screen comes into view.

    Read the full bite: React Navigation Lifecycle: Screens Don't Unmount

  26. Question 26 of 30

    Which statement accurately describes the Android system's involvement when a client app queries a ContentProvider?

    Show the answer

    Answer: b · The ActivityManagerService (AMS) resolves the URI, starts the provider's process if needed, and facilitates communication via a Binder proxy.

    The ActivityManagerService (AMS) is central to ContentProvider queries, resolving the URI, managing the provider's process lifecycle, and setting up the Binder communication. The query method executes on a Binder thread within the provider's process, not its main thread, and the provider is a singleton within its process.

    Read the full bite: How does Android manage a ContentProvider's lifecycle during a query?

  27. Question 27 of 30

    A component needs to fetch data from an API using an ID received via an @Input() property. Which lifecycle hook is the most appropriate for this initial data fetch?

    Show the answer

    Answer: c · The ngOnInit hook

    The card explicitly states that ngOnInit is for 'one-time initialization logic that depends on component inputs, like fetching data from an API based on an ID passed into the component.' The constructor is incorrect because input properties are not yet assigned their values at that stage.

    Read the full bite: Angular Component Lifecycle Hooks

  28. Question 28 of 30

    What is the consequence of returning a cleanup function from an asynchronous onMount callback in Svelte 5?

    Show the answer

    Answer: a · The cleanup function will not be registered, leading to potential memory leaks upon component destruction.

    An asynchronous onMount callback implicitly returns a Promise, not the cleanup function itself. Therefore, Svelte cannot register the intended cleanup function, which can lead to memory leaks. Option B is incorrect because the Promise is not interpreted as a cleanup function.

    Read the full bite: Svelte Lifecycle: Mount, Destroy, and Tick

  29. Question 29 of 30

    Which statement accurately compares lifecycle cleanup of reactive subscriptions in Vue 3's Composition API and Svelte?

    Show the answer

    Answer: d · Vue's watchEffect automatically cleans up its effect on unmount, while Svelte's dollar-prefixed store syntax generates lifecycle-bound subscribe and unsubscribe calls at compile time.

    Vue's watchEffect tracks dependencies and cleans up automatically on unmount, while Svelte's compiler auto-generates subscription management for dollar-prefixed stores. The first option is tempting because developers from Angular often assume Vue has template-level auto-subscription, but the Composition API does not provide this primitive.

    Read the full bite: Implement auto-cleanup reactive logic in Vue's Composition API and Svelte

  30. Question 30 of 30

    Which lifecycle method is the definitive place to release resources like an AnimationController when a StatefulWidget is permanently removed?

    Show the answer

    Answer: c · The dispose method, as it's called when the State object is permanently destroyed.

    The dispose method is explicitly for final resource cleanup when the State object is permanently removed and will never be used again. Deactivate, while indicating removal, is for temporary situations where the State object might be re-inserted into the tree.

    Read the full bite: Flutter's State Lifecycle: From Creation to Disposal

Could you explain these out loud?

That is what an interview actually tests. Tezvyn gives you questions like these with what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon