Top 50 Android Interview Questions and Answers by IT Trainings Institute
Introduction
Preparing for an Android Development interview? This Top 50 Android Interview Questions and Answers guide by IT Trainings Institute is your go-to resource for Android interview preparation—featuring commonly asked questions and answers to help both beginners and experienced candidates succeed. If you’re looking to strengthen your fundamentals, check out our comprehensive Android Development course to boost your knowledge and confidence.
So, let’s dive into this comprehensive collection of Android Technical Interview Questions and Answers, carefully categorized by IT Trainings Institute to support your interview preparation journey:
Android Interview Questions and Answers for Freshers
1. What is Android?
Answer:
Android is a mobile operating system developed by Google, based on the Linux kernel. It is primarily used for touchscreen mobile devices like smartphones and tablets. Android allows developers to build apps using Java, Kotlin, or C++.
2. What are the main components of Android?
Answer:
The main components are:
Activities – UI screens that users interact with
Services – Run in the background to perform tasks
Broadcast Receivers – Respond to system-wide events
Content Providers – Share data between applications
Fragments – Reusable parts of UI inside an activity
3. What is an Activity in Android?
Answer:
An Activity represents a single screen with a user interface. For example, a login screen or a home screen. Every Android app has at least one activity. Activities are managed using the Activity Lifecycle (onCreate, onStart, onResume, etc.).
4. What is an Intent?
Answer:
An Intent is a messaging object used to start activities, services, or broadcast receivers.
Explicit Intent: Starts a specific component (e.g., a class in your app)
Implicit Intent: Asks the system to find a component (e.g., opening a web page)
Intent intent = new Intent(this, SecondActivity.class);
startActivity(intent);
5. What is the AndroidManifest.xml file?
Answer:
The AndroidManifest.xml file provides essential information about the app to the Android system, including:
App components (Activities, Services)
Permissions (e.g., Internet, Camera)
App theme and icons
Entry point (MainActivity)
Learn via our Course
Level Up Your App Development Skills with Expert Android Training in Chandigarh & Mohali!
6. What is the difference between dp, sp, and px?
Answer:
dp (Density-independent Pixels): Used for layout; adjusts for screen density
sp (Scale-independent Pixels): Like dp, but scales with user’s font size (used for text)
px (Pixels): Exact pixels; not recommended due to inconsistent sizes on different screens
7. What is a Fragment in Android?
Answer:
A Fragment is a modular section of an activity. You can think of it as a mini-activity that can be combined into one UI. Fragments allow for flexible UI design, especially for tablets.
8. What is the difference between Service and IntentService?
Answer:
Service: Runs in the background; must manage its own thread
IntentService: Handles asynchronous tasks using a worker thread; stops automatically when the task is done
9. What is RecyclerView?
Answer:
RecyclerView is an advanced version of ListView. It is used to display large sets of data efficiently by reusing views. It requires a LayoutManager, Adapter, and ViewHolder to function.
10. What is ViewModel and LiveData?
Answer:
ViewModel: Stores and manages UI-related data during the lifecycle of an activity or fragment.
LiveData: A lifecycle-aware data holder that can be observed by UI components to update UI automatically.
They are part of Android Jetpack’s architecture components for modern app development.
11. What is an Adapter in Android?
Answer:
An Adapter acts as a bridge between a UI component (like a ListView or RecyclerView) and the underlying data source. It fetches data from the source and converts it into View objects that the UI component can display.
12. What is the Android Activity Lifecycle? Name its main callback methods.
Answer:
The Android Activity Lifecycle is the set of states an Activity goes through from its creation to its destruction. Understanding it is crucial for managing resources. The main callback methods are:
- onCreate(): Called when the activity is first created.
- onStart(): Called when the activity is becoming visible to the user.
- onResume(): Called when the activity will start interacting with the user (activity is at the top of the activity stack).
- onPause(): Called when the activity is losing foreground focus (another activity is coming into view).
- onStop(): Called when the activity is no longer visible to the user.
- onDestroy(): Called before the activity is destroyed.
- onRestart(): Called after the activity has been stopped, before it is started again.
13. What is the significance of the R.java file in Android?
Answer:
The R.java file is an auto-generated file by the Android build system. It contains static integer constants for all the resources in your project (e.g., layouts, drawables, strings, IDs of UI elements). This allows you to easily refer to resources in your Java/Kotlin code using R.layout.my_layout, R.id.my_button, etc.
14. What are Android Layouts? Name some common ones.
Answer:
Android Layouts are ViewGroup objects that define the structure for the user interface of an app. They serve as containers to hold and arrange View (UI elements) and other ViewGroup objects. Common layouts include:
- LinearLayout: Arranges elements in a single row or column.
- RelativeLayout: Positions elements based on relationships with each other or the parent container.
- ConstraintLayout: A flexible and powerful layout for complex UI hierarchies.
- FrameLayout: Used to block out an area on the screen to display a single item.
- TableLayout: Arranges elements into rows and columns, similar to an HTML table.
15. What is Android Studio?
Answer:
Android Studio is the official Integrated Development Environment (IDE) for Android app development, developed by Google. It provides a comprehensive set of tools for coding, debugging, testing, and deploying Android applications.
16. What is Gradle in Android?
Answer:
Gradle is an advanced build automation system used by Android Studio. It’s responsible for compiling, testing, and packaging your Android application. It allows you to manage project dependencies, configure build variants, and automate various development tasks.
17. Explain the purpose of Android Permissions.
Answer:
Android Permissions are mechanisms to protect user privacy and data. They define what an app is allowed to do or access on a user’s device (e.g., access camera, location, contacts, internet). Apps must declare the permissions they need in the AndroidManifest.xml file, and for sensitive permissions, users must explicitly grant them at runtime.
18. What is a Toast in Android?
Answer:
A Toast is a small, temporary, and non-intrusive popup message that appears on the screen for a short duration to provide feedback to the user, without interrupting the current activity. It automatically disappears after a set time.
19. What is AsyncTask? (And its alternatives)
Answer:
AsyncTask was a helper class that allowed performing background operations and publishing results on the UI thread without having to manipulate threads directly. However, it is now deprecated. Modern Android development recommends using alternatives like Kotlin Coroutines or RxJava for asynchronous operations, especially for complex or long-running tasks.
20. What is SharedPreferences in Android?
Answer:
SharedPreferences is a mechanism for storing small amounts of private primitive data in key-value pairs. It’s primarily used for saving user preferences, application settings, or any small data that needs to persist across app sessions.
21. What is a ContentProvider?
Answer:
A ContentProvider is one of the fundamental building blocks of Android applications. It acts as an interface for sharing data between different applications. It allows you to manage access to a central repository of data, enabling secure and structured data sharing.
22. What is an Android Emulator?
Answer:
An Android Emulator is a virtual Android device that runs on your computer. It allows developers to test their Android applications on various Android versions, screen sizes, and device configurations without needing physical devices, accelerating the development and testing process.
23. What is the difference between LinearLayout and RelativeLayout?
Answer:
- LinearLayout: Arranges UI elements in a single direction, either vertically or horizontally. Elements are stacked one after another.
- RelativeLayout: Positions UI elements based on their relationships with each other (e.g., “to the right of,” “below”) or with the parent container (e.g., “aligned with parent top,” “centered horizontally”). It allows for more complex and flexible layouts without deep nesting.
24. How do you debug an Android application?
Answer:
Debugging an Android application typically involves:
- Using Logcat to view system messages, errors, and custom log messages (Log.d(), Log.e(), etc.).
- Setting breakpoints in Android Studio to pause execution and inspect variables.
- Using the Debugger in Android Studio to step through code, evaluate expressions, and examine the call stack.
- Using the Android Device Monitor (DDMS) for advanced debugging tools.
25. What is a Build Flavors/Product Flavors in Android?
Answer:
Build flavors (or product flavors) in Android allow you to create different versions of your application from a single codebase. Each flavor can have its own distinct configurations, resources, dependencies, or code, enabling you to generate multiple APKs (e.g., free vs. paid versions, different branding).
26. What is Data Binding in Android?
Answer:
Data Binding is a library that allows you to declaratively bind UI components in your layouts to data sources in your app using a flexible and broad format. It reduces boilerplate code (e.g., findViewById()) and makes your layout files more dynamic and reactive to data changes.
27. What is a "Gradle Sync" in Android Studio?
Answer:
A “Gradle Sync” is the process where Android Studio syncs your project with the Gradle build system. This happens when you make changes to your build.gradle files (e.g., add new dependencies, change build configurations), ensuring that the IDE understands your project’s structure and dependencies.
28. What are Android Resources? Give examples.
Answer:
Android Resources are externalized assets that an application can use, such as images, strings, layouts, colors, and dimensions. Separating resources from code allows for easier localization, adaptability to different device configurations (e.g., screen sizes), and cleaner code.
Examples:
- res/layout/: XML files defining UI layouts.
- res/drawable/: Image files (PNG, JPEG), XML for shapes.
- res/values/: XML files for strings, colors, dimensions, styles.
- res/mipmap/: Launcher icons.
29. What is a Broadcast Receiver?
Answer:
A Broadcast Receiver is an Android component that allows an app to listen for and respond to system-wide broadcast announcements (Intents). These broadcasts can originate from the system (e.g., battery low, incoming SMS, screen on/off) or from other applications.
30. What is a Context in Android?
Answer:
Context is an interface in Android that provides access to application-specific resources and classes, as well as up-calls for application-level operations like launching activities, broadcasting intents, or accessing shared preferences. It basically represents the current state of the application or object. There are two main types: Application Context (tied to the application’s lifecycle) and Activity Context (tied to the activity’s lifecycle).
Android Interview Questions and Answers for Experienced
31. Explain the Android Application Architecture and its key components. How do they interact?
Answer:
The Android Application Architecture consists of several layers:
- Linux Kernel: Provides core system services (security, memory management, process management, network stack, driver model).
- Hardware Abstraction Layer (HAL): Standardized interface for hardware vendors to implement drivers.
- Android Runtime (ART): Executes Dalvik Executable (DEX) files, manages memory (Garbage Collection), and performs Ahead-Of-Time (AOT) compilation.
- Native C/C++ Libraries: OpenSSL, SQLite, OpenGL ES, WebKit, Media Framework, etc., used by the framework and applications.
- Java API Framework: Provides high-level building blocks for app development (Activity Manager, Package Manager, Content Providers, View System, Resource Manager, etc.).
- Applications: User-facing apps built using the framework.
- Interaction: Applications use the Java API Framework, which in turn leverages Native C/C++ Libraries, ART, and the HAL to interact with the Linux Kernel and hardware.
32. Differentiate between Activity, Service, BroadcastReceiver, and ContentProvider. Provide a real-world example for each.
Answer:
- Activity: A single screen with a user interface.
- Example: A login screen, a list of emails.
- Service: Performs long-running operations in the background, without a UI.
- Example: Downloading a file, playing music, fetching data from a network API periodically.
- Boardcast-reciver: Responds to system-wide broadcast announcements (e.g., battery low, SMS received, network connectivity changed).
- Example: An app receiving a broadcast when a new SMS arrives to display a notification.
- ContentProvider: Manages access to a structured set of data. It provides a standard interface for applications to query, insert, update, and delete data, even across different applications.
- Example: The Contacts app uses a ContentProvider to expose contact information to other applications.
33: Explain the Android Activity Lifecycle in detail. When would you use onSaveInstanceState() and onRestoreInstanceState()?
Answer: onSaveInstancesate ()and onRestoreInstancestate()?
- The Activity Lifecycle defines a set of callback methods that an Activitygoes through from creation to destruction. Key methods include:
- oncreate(): Called when the activity is first created
- onStart():Called when the activity is becoming visible to the user.
- onResum()
: Called when the activity will start interacting with the user.
- onPause(): Called when the system is about to resume a previous activity or another activity comes to the foreground.
- onStart (): Called when the activity is no longer visible to the use.
- onDestroy (): Called before the activity is destroyed.
- onRestart (): Called when the activity is restarted after being stopped.
- onSaveInstancestate ():andonStoreInstancestate: These methods are used to save and restore an ActivityUI state when the activity is destroyed and recreated due to a configuration change (e.g., screen rotation) or when the system kills the process to reclaim resources.
- onSaveInstancestate (): Called before stop or onDestroy. You put data into the Bundle provided.
- onSaveInstancestate(): Called after onStart() oronCreate() (if the Bundle is not null). You retrieve data from the Bundle.
34. What is the purpose of an Android Manifest file? What critical information does it contain?
The Android Manifest file, is an essential configuration file for every Android application. Its primary purpose is to provide fundamental information about your app to the Android operating system (OS) and to the Google Play Store (or other app stores). It acts as a blueprint for your application, declaring its core components, capabilities, permissions, and other crucial details that the system needs to understand and run your app correctly.
Purpose of the Android Manifest File:
- Declares Application Components: It informs the Android OS about all the app’s components (Activities, Services, Broadcast Receivers, Content Providers) that should be registered and managed by the system. Without this declaration, the OS wouldn’t know about these components and thus couldn’t launch or interact with them.
- Defines Permissions: It declares the permissions your application needs to access protected parts of the system or other applications (e.g., internet access, camera, contacts, location). It also declares any permissions that other applications must have to interact with components of your app.
- Specifies Hardware and Software Features: It specifies the hardware and software features that your application requires. This is crucial for Google Play to filter out devices that do not meet these requirements, ensuring your app is only installed on compatible devices.
- Declares Minimum and Target API Levels: It specifies the minimum Android version your app supports and the version it’s designed to run on (targetSdkVersion). This influences how the system behaves when running your app.
- Configures App Properties: It provides metadata about the application itself, such as its icon, label (name), theme, and whether it allows backups.
- Registers Intent Filters: It declares the types of intents your application’s components can respond to. This allows other apps or the system to start your components.
35. Explain the Android Application Architecture and its key components. How do they interact
Answer:
- The Aniroidmanifcl.xml file is the central configuration file for an Android application. It provides essential information about the app to the Android system.
- Critical Information name: Unique identifier for the application.
- Components: Declarations of all Activity,Service,Boarcdcast,Reciver, and ContentProvider,rovider components.
- Permissions: Permissions the app requires to access protected parts of the system or other apps’ data (e.g., Internet,Read, Read contact).
- Hardware and Software Features: Features the app requires (e.g., camera, NFC).
- Minimum API Level: minsdkversion.
- Target API Level: targetdkversion
.
- Icon and Label: For the application.
- Intent Filters: To declare what types of intents a component can respond to
36. Explain the concept of Intent and its types. How do you pass data between Activities using Intent?
Answer:
An Internet is a messaging object used to request an action from another app component. It acts as a bridge between components.
- Types of Intents:
- Explicit Intent: Specifies the exact component to start (e.g., starting a specific Activity by its class name).
- Implicit Intent: Declares a general action to perform, allowing the Android system to find the best component to handle it (e.g., opening a web page, sending an email).
- Passing Data: You can pass data using Internet with primitive types, String, Serializable, or Parcelable objects. To retrieve data, use getIntent().getExtra() methods (e.g., getIntent().getStringExtra(“KEY”). For custom objects, Parcelable is preferred overSerializable for performance reasons on Andr
37. Discuss different options for data storage in Android. When would you choose one over the others
Answer:
- SharedPreferences: Store small amounts of primitive data (key-value pairs).
- When to use: User preferences, settings, simple flags.
- Internal Storage: Store private data on the device’s file system, accessible only by your app.
- When to use: Sensitive data, large files specific to your app.
- External Storage: Store public data on the device’s shared external storage (SD card or shared internal storage), accessible by other apps (with permissions).
- When to use: Photos, videos, downloadable files that can be shared or accessed by other apps
- SQLite Databases: Store structured data in a private database.
- When to use: Large, structured datasets that require complex queries (e.g., contacts, messages, product catalogs).
- Network Connection: Store data on a remote server.
- When to use: Data that needs to be synchronized across multiple devices, accessed from a web interface, or managed by a backend.
38. Explain the Android Application Architecture and its key components. How do they interact?
Answer:
The Android Application Architecture consists of several layers:
- Linux Kernel: Provides core system services (security, memory management, process management, network stack, driver model).
- Hardware Abstraction Layer (HAL): Standardized interface for hardware vendors to implement drivers.
- Android Runtime (ART): Executes Dalvik Executable (DEX) files, manages memory (Garbage Collection), and performs Ahead-Of-Time (AOT) compilation.
- Native C/C++ Libraries: OpenSSL, SQLite, OpenGL ES, WebKit, Media Framework, etc., used by the framework and applications.
- Java API Framework: Provides high-level building blocks for app development (Activity Manager, Package Manager, Content Providers, View System, Resource Manager, etc.).
- Applications: User-facing apps built using the framework.
- Interaction: Applications use the Java API Framework, which in turn leverages Native C/C++ Libraries, ART, and the HAL to interact with the Linux Kernel and hardware.
39. Explain the advantages of using Room Persistence Library over raw SQLiteOpenHelper.
Answer:
Room is an ORM (Object Relational Mapping) library built on top of SQLite.
- Compile-time SQL Validation: Room validates SQL queries at compile time, catching errors early. SQLiteOpenHelper queries are validated at runtime.
- Boilerplate Reduction: Room reduces boilerplate code significantly by generating much of the SQL and mapping logic.
- Type Safety: It provides type-safe access to your database, reducing casting errors.
- LiveData& Flow Integration: Seamlessly integrates with LiveData and Kotlin Flow for reactive UI updates when data changes.
- Migrations: Provides robust mechanisms for handling database migrations.
- Easier Testing: Easier to test database interactions.
40. Differentiate between ConstraintLayout, LinearLayout, and RelativeLayout. When would you prefer one over the others?
Answer:
- RecyclerView is a more advanced and flexible successor to ListView for displaying large sets of data efficiently.
Advantages over ListView:
- Recycling Views: Only creates as many ViewHolders can fit on the screen, then recycles them for new data as the user scrolls. ListView also recycles but RecyclerView’s mechanism is more explicit and efficient.
- Layout Managers: Decouples layout management from the view itself, allowing for different layouts (linear, grid, staggered grid).
- Item Decorators: Provides flexible ways to add dividers, spacing, etc.
- Item Animators: Easily add animations for item additions, removals, and movements.
- Built-in DiffUtil: Helps optimize updates by calculating the minimal set of changes between two lists.
- Optimizing RecyclerView’s Performance:
- ViewHolder Pattern: Essential for recycling views.
- DiffUtil: Use DiffUtil for partial updates instead of notifyDataSetChanged().
- setHasFixedSize(true) setHasFixedSize(true) If the RecyclerView size doesn’t change with content.Stable IDs
: If your items have unique and stable IDs, use setHasStableIds and override getItemId().
- Pre-fetching: For complex item layouts, consider pre-fetching data.
- Avoid complex view hierarchies in item layouts.
- Lazy Loading Images: Use libraries like Glide or Picasso.
41. Explain ViewModel in detail. How does it address challenges with configuration changes?
Answer:
- A ViewModel is designed to store and manage UI-related data in a lifecycle-conscious way. It allows data to survive configuration changes (like screen rotations) without needing to be re-fetched.
- How it addresses challenges: When an Activity or Fragment is recreated due to a configuration change, the existing ViewModel instance is retained and re-associated with the new Activity/Fragment instance. This means any data or operations within the ViewModel persist, providing a seamless user experience
42. Discuss Kotlin Coroutines and Flow for asynchronous programming in Android.
Answer:
- Coroutines: Lightweight threads that allow writing asynchronous, non-blocking code in a sequential style. Explain suspend functions, launch/async builders, and CoroutineScope.
- Flow: An asynchronous data stream that can emit multiple values. It’s built on top of coroutines and is a reactive stream API. Explain hot vs. cold flows, collectors, and various operators (map, filter, debounce, etc.).
- Benefits: Simplified asynchronous code, structured concurrency, better error handling, improved readability compared to callbacks.
43. How do you handle dependency injection in Android? Compare Dagger/Hilt with Koin/Kodein.
Answer:
- Dependency Injection (DI): A technique where objects are supplied with their dependencies by an external entity, rather than creating them themselves. This improves testability, modularity, and maintainability.
- Dagger/Hilt: Compile-time DI frameworks.
- Dagger: Powerful, highly performant, but has a steep learning curve and generates a lot of boilerplate.
- Hilt: Built on top of Dagger, reduces boilerplate significantly, especially for Android-specific components, by providing standard components and bindings.
- Koin/Kodein: Runtime DI frameworks.
- Koin/Kodein: Simpler to set up and use, less boilerplate, but might have a slight runtime performance overhead compared to compile-time solutions.
- When to choose: Dagger/Hilt for large, complex projects where compile-time safety and performance are paramount. Koin/Kodein for smaller projects or if rapid development and simplicity are prioritized.
44. Explain RecyclerView. How does it optimize list rendering compared to ListView?
Answer:
RecyclerView is a more flexible and performant view for displaying large sets of data.
- Optimizations over ListView:
- ViewHolder pattern enforcement: RecyclerView explicitly requires and enforces the ViewHolder pattern, which recycles views, reducing findViewById calls and object creation.
- LayoutManager: Decouples layout and scrolling behavior from the adapter, allowing for different layouts (linear, grid, staggered grid).
- ItemAnimator: Provides default animations for item changes (add, remove, move).
- ItemDecoration: Allows for custom drawing and spacing between items
45. What is Jetpack Compose? How does it differ from the traditional Android View system?
Answer: Jetpack Compose is a modern, declarative UI toolkit for building native Android UIs.
- Differences from traditional View system (XML-based):
- Declarative vs. Imperative: Compose describes the UI’s state, and the framework updates it automatically. The traditional View system requires manual manipulation of views (e.g., setText, setVisibility).
- Kotlin-first: Built entirely in Kotlin.
- Less XML: Significantly reduces or eliminates the need for XML layouts.
- Direct UI manipulation: Composable functions directly emit UI elements.
- Recomposition: Compose intelligently re-renders only the parts of the UI that have changed, leading to potentially better performance.
- Easier state management: Built-in state management with remember, mutableStateOf, Flow.
46. How do you handle different screen sizes and orientations in Android?
Answer:
- Responsive Layouts: Use ConstraintLayout for flexible UIs, LinearLayout with weights, and responsive design.
- Resource Qualifiers: Provide alternative layouts, drawables, dimensions (dimens.xml), and values (values.xml) based on screen size (sw600dp, land), density (hdpi, xhdpi), and orientation.
- Fragments: Use Fragments to create modular UI components that can be combined differently on various screen sizes (e.g., master-detail flow on tablets).
- Window insets: For handling system bars and notches.
- Jetpack Compose: Composables are inherently more adaptable and responsive due to their declarative nature and built-in layout modifiers.
47. Compare and contrast different data persistence options in Android (Shared Preferences, Room, Files). When would you use each?
Answer:
- SharedPreferences: For storing small amounts of primitive data (key-value pairs) like user preferences, settings. Not suitable for complex data or large datasets.
- Room Persistence Library: An abstraction layer over SQLite. Ideal for structured, relational data. Provides compile-time checks, type safety, and handles boilerplate for database operations. Recommended for most local data storage needs.
- Internal/External Storage (Files): For large files, custom data formats, or data that doesn’t fit well into a relational database.
- Internal Storage: App-private, secure, automatically deleted with app uninstall.
- External Storage: Accessible by other apps (with permissions), persists after app uninstall.
- DataStore: A modern, improved alternative to SharedPreferences for simple key-value pairs or typed objects with protocol buffers. Offers asynchronous APIs and data consistency guarantees.
48. Explain the Room Persistence Library in detail, including its components (Entities, DAOs, Database).
Answer:
-
- Room simplifies SQLite database interactions.
- Entity: Represents a table in the database. A class annotated with @Entity.
- DAO (Data Access Object): An interface or abstract class annotated with @Dao that defines methods for interacting with the database (insert, update, delete, query). Room generates the implementation at compile time.
- Database: An abstract class annotated with @Database that extends RoomDatabase It holds the database and serves as the main access point for the underlying connection.
- Benefits: Compile-time verification of SQL queries, reduced boilerplate, integrates with LiveData/Flow for observable queries, better error handling.
49. Describe your approach to testing an Android application. What types of tests do you write?
Answer:
Emphasize a layered testing approach:
- Unit Tests: Test individual components (e.g., ViewModel, Model, utility classes) in isolation, often on the JVM. Use Mockito/Kotest for mocking.
- Integration Tests: Test interactions between multiple components (e.g., ViewModel and Repository, DAO and Database). Can be run on JVM or device/emulator.
- UI Tests (Instrumentation Tests): Test the UI and user interactions on a device or emulator. Use Espresso for UI interactions and assertions.
- End-to-End Tests: Test the entire user flow.
50. How do you test asynchronous code (e.g., Coroutines, LiveData) in Android?
Answer:
- Coroutines: Use kotlinx-coroutines-test
for structured concurrency testing. Inject test dispatchers to control execution.
- LiveData: Use InstantTaskExecutorRule
for synchronous execution of LiveData operations on the test thread. Observe LiveData values and assert changes.
- Mocking: Mock dependencies (e.g., network calls, database operations) to isolate the code being tested.