Model answers for 4 Android questions
Typical round: concepts, architecture discussion, one small coding task
Q: How does ViewModel survive rotation? A: The ViewModel is stored in a ViewModelStore tied to the activity or fragment, which is retained across configuration changes. It is cleared only when the owner is finished for good, so UI state and in-flight work survive rotation.
Q: What causes an ANR and how do you avoid it? A: An ANR happens when the main thread is blocked, for example around 5 seconds without responding to input. Move disk, network and heavy work to coroutines on Dispatchers.IO or Default, and keep the main thread for UI.
Q: How does state work in Jetpack Compose? A: Composables read state, and when that state changes Compose recomposes the functions that read it. Use remember for state in a composable, rememberSaveable to survive rotation, and hoist state to a ViewModel for screen logic.
Q: How do you find memory leaks? A: Use LeakCanary in debug builds. Common causes are holding an Activity context in a long-lived object, unremoved listeners, and coroutines not tied to a lifecycle scope.