10/181 questions · Unlock full access
Q1

A junior developer is building a Jetpack Compose screen that displays a list of user profiles. They've noticed that whenever a single profile's 'like' status changes, the entire list recomposes, causing performance issues. The senior developer suggests using 'state hoisting'. What is the primary goal of state hoisting in this context?

Q2

An application uses a Room database with a DAO that returns a `Flow >` to observe data changes. The UI layer collects this flow, but under heavy database write loads, the UI freezes because it's receiving updates too frequently. Which Flow operator is the most appropriate solution to apply before collecting the flow in the UI layer to mitigate this issue without losing the final state?

Q3Multiple answers

A developer needs to schedule a background task using WorkManager that should only run when the device has a certain level of battery and is connected to a Wi-Fi network. Which of the following constraints should be applied to the `WorkRequest`? (Select TWO)

Q4

When writing a unit test for a `ViewModel` that uses `viewModelScope` to launch coroutines, what is the modern, recommended approach to manage the `Dispatchers.Main` dispatcher and control coroutine execution within a JUnit test?

Q5

To clear all data for a specific application package during development, a developer can use the Android Debug Bridge (adb). The command to achieve this is: `adb shell pm clear ______`.

Q6

**Company Background:** `FitLife` is a fitness tracking company modernizing its Android application. The current app was built five years ago using XML layouts and the traditional View system. The UI is inconsistent, slow to render complex screens, and difficult to maintain due to deeply nested `LinearLayouts` and `RelativeLayouts` inside a `ScrollView`. **Current Situation:** The main dashboard screen is particularly problematic. It displays user stats, a list of recent workouts, and daily challenges. All this data comes from a `DashboardViewModel` which exposes several `LiveData` objects. The XML for this screen is over 800 lines long. **Requirements:** The CTO has mandated a full migration of the dashboard screen to Jetpack Compose to improve performance and maintainability. The new implementation must: 1. Be built entirely with declarative UI components. 2. Observe the existing `LiveData` objects from the `DashboardViewModel` in a lifecycle-aware manner. 3. Replace the `RecyclerView` for recent workouts with a lazy-loading list in Compose. 4. Ensure the new UI is themable and supports Material 3 design principles. Which of the following approaches is the most effective and idiomatic way to implement the new Jetpack Compose dashboard screen based on the requirements? ```mermaid flowchart TD subgraph ViewModel A[LiveData ] B[LiveData >] C[LiveData ] end subgraph Compose UI D{DashboardScreen} E[StatsCard] F[WorkoutList] G[ChallengeBanner] end ViewModel --> D D --> E D --> F D --> G ```

Q7

True or False: Jetpack DataStore is a direct, drop-in replacement for SharedPreferences and uses the same synchronous, file-based I/O API on the main thread.

Q8

On Android 14 (API 34), an app that needs to perform a long-running task like a data sync must declare a foreground service. What is the critical requirement that the app must fulfill when calling `startForeground()` for a service related to data synchronization?

Q9

In an Espresso UI test, the app performs a network request that takes an unpredictable amount of time to complete before updating a `TextView`. The test intermittently fails with an `NoMatchingViewException` because the assertion runs before the `TextView` is updated. What is the most robust and recommended way to make Espresso wait for this asynchronous operation to complete?

Q10

In Jetpack Compose, a developer needs to display a potentially very long, vertically scrolling list of items. To ensure good performance, only the items visible on screen should be composed and rendered. Which composable should be used?