Skip to main content
InterviewHubPRO
Section Overview
Q2

Question 2 of 50

Part 1: Architecture, Jetpack Compose & Core Components (1 - 10)

4%
Android & Jetpack Compose (50 Qs)•Part 1: Architecture, Jetpack Compose & Core Components (1 - 10)

What is Jetpack Compose and how does it differ from traditional XML-based Views?

senior LevelCode ExampleComponentsDocker & ContainersSystem Design

In Simple Words: Jetpack Compose is Android's modern declarative UI toolkit:

  • Imperative XML Views (Legacy): UI declared in XML layout files; mutated imperatively in Kotlin/Java code by traversing the view hierarchy (findViewById(), setText(), setVisibility()). Prone to state synchronization bugs.
  • Declarative Compose (Modern): UI is defined as Kotlin @Composable functions that describe what the UI should look like for a given state. When state changes, Compose automatically recomposes only the affected composable functions!
kotlin
// Jetpack Compose Example:
@Composable
fun CounterButton() {
    var count by remember { mutableStateOf(0) }
    Button(onClick = { count++ }) {
        Text("Clicked $count times")
    }
}