Android MVVM Architecture
MVVM Architecture with Jetpack: ViewModel, LiveData, Data Binding, Separation of Concerns, Unidirectional Data Flow
18 面接問題·
Mid-Level
1What is a ViewModel in Android?
1
What is a ViewModel in Android?
回答
A ViewModel is a Jetpack component that stores and manages UI-related data in a lifecycle-aware way. It survives configuration changes (screen rotation) and allows separating business logic from UI.
2How do you create a ViewModel instance in an Activity?
2
How do you create a ViewModel instance in an Activity?
回答
Use ViewModelProvider to create or retrieve a ViewModel instance. ViewModelProvider(this).get(MyViewModel.class) ensures you get the same instance even after screen rotation.
3Why should you never pass an Activity or View Context into a ViewModel?
3
Why should you never pass an Activity or View Context into a ViewModel?
回答
The ViewModel survives configuration changes and lives longer than Activities. Keeping an Activity Context reference would cause a memory leak. Use AndroidViewModel with Application Context if needed.
4
What is LiveData?
5
What is the difference between LiveData and MutableLiveData?
+15 面接問題
その他のAndroid面接トピック
Android Fundamentals
Junior
24問Android UI and Resources
Junior
30問Android Lifecycle
Junior
30問Android Navigation
Junior
26問Android Data Management
Junior
29問Android Networking
Junior
29問Android Testing
Junior
28問Android Gradle
Junior
26問Kotlin Language Essentials for Android
Junior
24問Room Database
Mid-Level
25問Background Work
Mid-Level
18問Jetpack Compose
Mid-Level
28問Permissions and Device Features
Mid-Level
21問Firebase for Android
Mid-Level
23問Advanced Android Networking
Mid-Level
13問Kotlin Collections and Operators
Mid-Level
20問Kotlin Coroutines and Flow
Mid-Level
20問Android Dependency Injection
Mid-Level
15問Android MVI Architecture
Mid-Level
17問Android Clean Architecture
Senior
21問Android Compose Advanced
Senior
17問Android Performance and Monitoring
Senior
13問Android Security and Privacy
Senior
18問Android CI/CD and Release
Senior
15問Android UX and Form Factors
Senior
18問Android Testing Advanced
Senior
18問