Recall & Review
beginner
What does MVVM stand for in Android development?
MVVM stands for Model-View-ViewModel. It is a design pattern that helps separate the user interface (View) from the business logic (Model) using a ViewModel as a bridge.
Click to reveal answer
beginner
What is the role of the ViewModel in MVVM?
The ViewModel holds and manages UI-related data. It communicates with the Model to get data and prepares it for the View. It survives configuration changes like screen rotations.
Click to reveal answer
intermediate
How does the View observe data changes in MVVM?
The View observes LiveData or StateFlow objects exposed by the ViewModel. When data changes, the View automatically updates without manual intervention.
Click to reveal answer
intermediate
Why is MVVM better than putting all code in the Activity or Fragment?
MVVM separates concerns, making code easier to read, test, and maintain. It prevents Activities or Fragments from becoming too large and handles lifecycle changes better.
Click to reveal answer
intermediate
In MVVM, where should network or database operations be performed?
Network or database operations should be done in the Model or Repository layer. The ViewModel requests data from the Model and exposes it to the View.
Click to reveal answer
In MVVM, which component directly updates the UI?
✗ Incorrect
The View is responsible for displaying the UI and updating it based on data changes.
Which Android class is commonly used in ViewModel to hold observable data?
✗ Incorrect
LiveData is an observable data holder class that the View can observe for changes.
What is a key benefit of using ViewModel in MVVM?
✗ Incorrect
ViewModel survives configuration changes like screen rotations, preserving UI data.
Where should business logic be placed in MVVM?
✗ Incorrect
Business logic belongs in the Model layer, keeping ViewModel focused on UI data preparation.
Which of these is NOT a responsibility of the ViewModel?
✗ Incorrect
User input events are usually handled by the View, which then informs the ViewModel.
Explain the roles of Model, View, and ViewModel in the MVVM pattern.
Think about who does what in the app: data, UI, and the middleman.
You got /3 concepts.
Describe how MVVM helps manage screen rotations in Android apps.
Consider what happens when the screen turns and the Activity restarts.
You got /3 concepts.