×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

MVVM (Model-View-ViewModel) MCQs (Multiple-Choice Questions)

MVVM (Model-View-ViewModel) is a software architectural pattern that separates the user interface, application data, and presentation logic. It is widely used with technologies such as WPF, .NET MAUI, and other data-binding-based UI frameworks. These MVVM MCQs cover Model, View, ViewModel, data binding, commands, INotifyPropertyChanged, ICommand, ObservableCollection<T>, DataContext, BindingContext, and testability.

MVVM MCQs

Practice these MVVM multiple-choice questions to test your understanding of the Model-View-ViewModel pattern and its implementation in modern application development.

List of MVVM MCQs

The following MVVM MCQs include answers and explanations covering fundamental concepts as well as practical data-binding and command scenarios.

1. What does MVVM stand for?

  1. Model-View-ViewModel
  2. Model-Visual-Variable-Model
  3. Module-View-Value-Manager
  4. Model-Version-View-Manager

Answer: A) Model-View-ViewModel

Explanation:

MVVM stands for Model-View-ViewModel. It separates an application's data and business concerns from its user interface and presentation logic.

2. What is the primary purpose of the MVVM pattern?

  1. To tightly couple UI controls with database tables
  2. To separate UI, presentation logic, and application data
  3. To eliminate all application models
  4. To replace object-oriented programming

Answer: B) To separate UI, presentation logic, and application data

Explanation:

MVVM separates the View, ViewModel, and Model responsibilities, making the application easier to maintain, test, and evolve.

3. Which MVVM component is primarily responsible for the user interface?

  1. Model
  2. View
  3. ViewModel
  4. Repository

Answer: B) View

Explanation:

The View represents the visual interface and its presentation-related behavior. In frameworks such as WPF, the View commonly consists of XAML and associated UI code.

4. What is the primary responsibility of the Model in MVVM?

  1. Defining button colors
  2. Representing application data and domain or business logic
  3. Handling every UI event directly
  4. Rendering XAML controls

Answer: B) Representing application data and domain or business logic

Explanation:

The Model represents application data and domain concepts and can contain business and validation logic. It is not responsible for rendering the user interface.

5. What is the primary responsibility of the ViewModel?

  1. Rendering pixels on the screen
  2. Providing presentation data, state, and commands for the View
  3. Replacing the database server
  4. Defining the application's operating system

Answer: B) Providing presentation data, state, and commands for the View

Explanation:

The ViewModel exposes properties and commands that the View can bind to. It also coordinates interactions with Model classes and services.

6. Which relationship is generally intended between a View and its ViewModel?

  1. The ViewModel directly manipulates every visual control
  2. The View binds to properties and commands exposed by the ViewModel
  3. The ViewModel inherits from every View
  4. The View and ViewModel must always be the same class

Answer: B) The View binds to properties and commands exposed by the ViewModel

Explanation:

MVVM uses data binding and commands to allow the View to consume functionality exposed by the ViewModel without requiring the ViewModel to directly manipulate individual UI controls.

7. Which object commonly connects a WPF View to its ViewModel for data binding?

  1. DataContext
  2. ConnectionString
  3. ApplicationDomain
  4. ResourceManager

Answer: A) DataContext

Explanation:

In WPF, data binding expressions commonly resolve their source through the DataContext of the element or its binding context inheritance chain.

8. In .NET MAUI, which property normally provides the binding source for a View?

  1. BindingContext
  2. DataSource
  3. ViewModelContext
  4. ModelContext

Answer: A) BindingContext

Explanation:

In .NET MAUI, the BindingContext is commonly set to a ViewModel instance so that XAML bindings can resolve its properties and commands.

9. What is data binding in MVVM?

  1. A mechanism for connecting UI properties with data or properties exposed by another object
  2. A database backup mechanism
  3. A method for compiling XAML into SQL
  4. A technique for encrypting ViewModels

Answer: A) A mechanism for connecting UI properties with data or properties exposed by another object

Explanation:

Data binding connects properties of UI elements with properties exposed by a binding source such as a ViewModel.

10. Which binding mode allows changes in the UI to update the bound source as well as changes in the source to update the UI?

  1. OneWay
  2. OneTime
  3. TwoWay
  4. OneWayToSource

Answer: C) TwoWay

Explanation:

TwoWay binding allows data to flow in both directions: changes in the source can update the target, and changes in the target can update the source.

11. Which interface is commonly implemented by a ViewModel to notify the View when a property value changes?

  1. IEnumerable
  2. INotifyPropertyChanged
  3. IDisposable
  4. IComparable

Answer: B) INotifyPropertyChanged

Explanation:

INotifyPropertyChanged provides the PropertyChanged event, allowing data-bound controls to be notified when a property changes.

12. Which event is defined by INotifyPropertyChanged?

  1. ValueChanged
  2. PropertyChanged
  3. DataUpdated
  4. BindingChanged

Answer: B) PropertyChanged

Explanation:

The PropertyChanged event is raised when the value of a property changes so that data-binding clients can refresh the corresponding UI.

13. What information does PropertyChangedEventArgs provide?

  1. The name of the property that changed
  2. The database connection string
  3. The View's screen resolution
  4. The application's assembly version only

Answer: A) The name of the property that changed

Explanation:

PropertyChangedEventArgs contains the PropertyName property, which identifies the property whose value changed.

14. Which statement best describes the ViewModel's relationship with a specific View implementation?

  1. The ViewModel should normally directly manipulate controls in the View
  2. The ViewModel should ideally avoid direct dependency on a specific View implementation
  3. The ViewModel must inherit from the View
  4. The ViewModel must contain the View's XAML

Answer: B) The ViewModel should ideally avoid direct dependency on a specific View implementation

Explanation:

A ViewModel is intended to encapsulate presentation logic without directly depending on a particular View implementation. This helps maintain loose coupling and testability.

15. Which interface is commonly used to represent commands in .NET MVVM applications?

  1. ICommand
  2. IAction
  3. IEventCommand
  4. IUICommandOnly

Answer: A) ICommand

Explanation:

ICommand represents an operation that can be invoked by the View and commonly exposes Execute and CanExecute functionality.

16. Which ICommand member determines whether a command can currently execute?

  1. CanExecute
  2. IsEnabled
  3. AllowExecute
  4. ExecuteState

Answer: A) CanExecute

Explanation:

CanExecute determines whether the command can execute for a specified parameter. UI controls can use this information to enable or disable command-bound controls.

17. Which ICommand member performs the command operation?

  1. Run
  2. Execute
  3. Perform
  4. InvokeCommand

Answer: B) Execute

Explanation:

The Execute method contains or invokes the operation represented by the command.

18. What is the purpose of CanExecuteChanged in ICommand implementations?

  1. To notify command consumers that the result of CanExecute may have changed
  2. To notify the database that a row changed
  3. To reload the entire View
  4. To destroy the command object

Answer: A) To notify command consumers that the result of CanExecute may have changed

Explanation:

CanExecuteChanged allows command consumers to reevaluate whether the command can currently execute.

19. Which ViewModel member is commonly bound to a Button's Command property?

  1. An ICommand implementation
  2. A database table
  3. A XAML document
  4. A CSS selector

Answer: A) An ICommand implementation

Explanation:

A ViewModel can expose an ICommand property that a Button or another command-capable control binds to, allowing the View to invoke the ViewModel's action.

20. What is the main advantage of using commands instead of placing button logic directly in code-behind?

  1. Commands help separate user actions from their visual representation
  2. Commands eliminate the need for data
  3. Commands automatically create database tables
  4. Commands make all UI elements static

Answer: A) Commands help separate user actions from their visual representation

Explanation:

Commands allow actions to be exposed by the ViewModel and invoked through data binding, reducing direct coupling between UI controls and application logic.

21. Which collection is particularly useful for notifying a bound UI when items are added or removed?

  1. List<T>
  2. ObservableCollection<T>
  3. Stack<T>
  4. HashSet<T>

Answer: B) ObservableCollection<T>

Explanation:

ObservableCollection<T> implements collection-change notification, allowing data-bound controls to respond when items are added, removed, or otherwise changed in the collection structure.

22. Which interface provides collection-change notifications?

  1. INotifyCollectionChanged
  2. INotifyListChanged
  3. ICollectionNotification

Answer: A) INotifyCollectionChanged

Explanation:

INotifyCollectionChanged defines the CollectionChanged event used to notify consumers about changes to a collection.

23. Which of the following is a common benefit of MVVM for unit testing?

  1. ViewModel logic can often be tested without creating the actual UI
  2. Every test must render the complete application window
  3. Models cannot be tested independently
  4. Unit tests must execute XAML animations

Answer: A) ViewModel logic can often be tested without creating the actual UI

Explanation:

Because ViewModels can encapsulate presentation logic independently of visual controls, much of their behavior can be tested without requiring the actual UI.

24. Which characteristic helps MVVM reduce coupling between the View and ViewModel?

  1. Direct control manipulation from the ViewModel
  2. Data binding and commands
  3. Global variables for every UI element
  4. Static references to all Views

Answer: B) Data binding and commands

Explanation:

Data binding allows Views to consume ViewModel properties, while commands expose user actions without requiring the ViewModel to directly manipulate visual controls.

25. In a well-separated MVVM design, which component should normally know about the View's visual implementation?

  1. The View
  2. The Model
  3. The ViewModel
  4. The data repository

Answer: A) The View

Explanation:

The View is responsible for the visual presentation. The Model should not know about the UI, and the ViewModel should ideally avoid direct dependency on a specific View implementation.

26. Which layer typically coordinates interaction between the View and Model?

  1. ViewModel
  2. View only
  3. Database engine
  4. CSS layer

Answer: A) ViewModel

Explanation:

The ViewModel commonly coordinates the View's interactions with Model classes and services while exposing data and actions in a form suitable for the View.

27. What is the purpose of a value converter in a data-binding system?

  1. To transform a value between the form required by the source and target
  2. To create a database connection
  3. To compile the ViewModel
  4. To replace every command

Answer: A) To transform a value between the form required by the source and target

Explanation:

A value converter can transform bound values between representations required by the source and the target, such as converting a Boolean value to a UI visibility representation.

28. In WPF, what does a binding Path generally specify?

  1. The property or property path to obtain the bound value from the source
  2. The location of the executable file
  3. The database server name
  4. The CSS file used by the View

Answer: A) The property or property path to obtain the bound value from the source

Explanation:

The Path property identifies the source property or nested property path used by a binding.

29. Which binding mode displays source changes in the target but does not normally propagate target changes back to the source?

  1. TwoWay
  2. OneWay
  3. OneWayToSource
  4. ReverseTwoWay

Answer: B) OneWay

Explanation:

OneWay binding normally propagates changes from the source to the target, while changes made to the target do not update the source through that binding.

30. Which binding mode is intended primarily for sending target changes back to the source?

  1. OneWayToSource
  2. OneWay
  3. OneTime
  4. SourceOnly

Answer: A) OneWayToSource

Explanation:

OneWayToSource transfers changes from the target back to the source rather than providing normal source-to-target updates.

31. Why should a ViewModel raise PropertyChanged when a calculated property changes?

  1. So controls bound to the calculated property can refresh
  2. So the database automatically creates an index
  3. So the ViewModel becomes a View
  4. So XAML can be deleted

Answer: A) So controls bound to the calculated property can refresh

Explanation:

If a calculated property's result depends on another property, a change notification for the calculated property may be required so that bound controls obtain its new value.

32. Which approach is generally discouraged in MVVM when the same behavior can be expressed through binding or commands?

  1. Putting application logic directly into UI event handlers in code-behind
  2. Exposing ViewModel properties
  3. Using ICommand
  4. Using data binding

Answer: A) Putting application logic directly into UI event handlers in code-behind

Explanation:

MVVM generally places presentation logic and user actions in the ViewModel where appropriate, using binding and commands instead of coupling application logic to UI event handlers.

33. Which statement about the Model and View is correct in MVVM?

  1. The Model should normally be responsible for rendering UI controls
  2. The Model should normally remain unaware of the View
  3. The Model must inherit from the View
  4. The View must directly execute every database operation

Answer: B) The Model should normally remain unaware of the View

Explanation:

The Model represents application or domain data and logic and should not depend on the visual representation of that data.

34. What is the purpose of a DataTemplate in an MVVM-based UI framework such as WPF?

  1. To define how an object is visually represented
  2. To create a SQL database
  3. To implement an HTTP server
  4. To replace the ViewModel

Answer: A) To define how an object is visually represented

Explanation:

A DataTemplate defines the visual structure used to display an object. In MVVM applications, it can provide the View representation for a ViewModel.

35. What does loose coupling mean in an MVVM context?

  1. Components have fewer direct dependencies on specific implementations
  2. All classes must be in one file
  3. The ViewModel must directly reference every UI control
  4. The Model must inherit from the View

Answer: A) Components have fewer direct dependencies on specific implementations

Explanation:

Loose coupling means components communicate through abstractions, binding, commands, or services rather than relying heavily on concrete implementations of other components.

36. Which design characteristic makes a ViewModel particularly suitable for unit testing?

  1. It contains all visual controls
  2. It can encapsulate presentation logic independently of the UI
  3. It must inherit from Window
  4. It must directly manipulate XAML elements

Answer: B) It can encapsulate presentation logic independently of the UI

Explanation:

A ViewModel can expose state and behavior without requiring direct access to visual controls, making its logic easier to test independently.

37. A ViewModel contains an IsBusy property that changes while an asynchronous operation is running. What should typically happen when its value changes?

  1. The ViewModel should notify the View through property change notification
  2. The ViewModel should recreate the entire application window
  3. The Model should modify the XAML directly
  4. The database should raise a UI event

Answer: A) The ViewModel should notify the View through property change notification

Explanation:

If a View is bound to IsBusy, the ViewModel should raise the appropriate property change notification when its value changes so that the UI can update.

38. A Button should only be enabled when a ViewModel's CanSubmit condition is true. Which MVVM mechanism is appropriate?

  1. ICommand.CanExecute
  2. Direct manipulation of Button.IsEnabled from the Model
  3. Changing the database schema
  4. Replacing the ViewModel with a View

Answer: A) ICommand.CanExecute

Explanation:

A command can expose whether an action is currently executable through CanExecute. A command-aware control can use this information to determine whether the UI action should be enabled.

39. What is CommandParameter used for?

  1. Passing a value or object to a command when it executes
  2. Defining a database connection
  3. Changing the View's XAML namespace
  4. Creating a new ViewModel class automatically

Answer: A) Passing a value or object to a command when it executes

Explanation:

CommandParameter allows a View to provide an argument to the command when the command is invoked.

40. Which approach can be used to provide dependencies to a ViewModel while maintaining loose coupling?

  1. Dependency injection
  2. Direct access to every UI control
  3. Global UI variables
  4. Hard-coded database credentials

Answer: A) Dependency injection

Explanation:

Dependency injection can provide services and other dependencies to a ViewModel without requiring the ViewModel to construct concrete dependencies itself.

41. Which type of operation should generally be handled asynchronously in a ViewModel when it involves potentially long-running I/O?

  1. Network or file I/O
  2. Reading a local constant
  3. Returning a Boolean literal
  4. Assigning a string literal

Answer: A) Network or file I/O

Explanation:

Asynchronous operations can prevent long-running I/O from blocking the UI thread and help keep the application responsive.

42. Which MVVM concept allows a UI element to invoke ViewModel functionality without knowing how the functionality is implemented?

  1. Command binding
  2. Direct control inheritance
  3. UI field injection
  4. Visual tree replacement

Answer: A) Command binding

Explanation:

Command binding connects a UI action to a command exposed by the ViewModel, keeping the UI interaction separate from the command's implementation.

43. Which of the following is a common MVVM framework or toolkit for .NET applications?

  1. .NET Community MVVM Toolkit
  2. SQL Server Reporting Engine
  3. ASP.NET Razor Compiler only
  4. Windows Registry API

Answer: A) .NET Community MVVM Toolkit

Explanation:

The .NET Community MVVM Toolkit provides helpers and source-generator-based features for implementing MVVM patterns in .NET applications.

44. Which statement best describes the ViewModel's properties?

  1. They provide data and state in a form that the View can consume
  2. They must always be references to visual controls
  3. They can only contain database connection strings
  4. They must always be static

Answer: A) They provide data and state in a form that the View can consume

Explanation:

A ViewModel exposes properties that represent presentation state and data needed by the View. It may also transform or combine model data into a form suitable for display.

45. Which statement about a ViewModel is correct?

  1. A ViewModel must inherit from a WPF Window
  2. A ViewModel is normally a non-visual class
  3. A ViewModel must contain XAML markup
  4. A ViewModel must directly manipulate the visual tree

Answer: B) A ViewModel is normally a non-visual class

Explanation:

A ViewModel normally does not derive from a visual UI class. It encapsulates presentation logic, state, properties, and commands that can be consumed by the View.

46. Consider the following ViewModel property:

private string _name;

public string Name
{
    get => _name;
    set
    {
        _name = value;
        OnPropertyChanged(nameof(Name));
    }
}

What is the primary purpose of OnPropertyChanged(nameof(Name))?

  1. To notify data-bound UI elements that Name has changed
  2. To create a new database table named Name
  3. To execute a command named Name
  4. To instantiate the ViewModel

Answer: A) To notify data-bound UI elements that Name has changed

Explanation:

The property change notification tells the binding system that the Name property's value has changed, allowing controls bound to Name to refresh their displayed value.

47. Consider the following command binding:

<Button
    Content="Save"
    Command="{Binding SaveCommand}" />

Where would SaveCommand normally be defined in an MVVM application?

  1. In the ViewModel
  2. In the database schema
  3. In the operating system
  4. In the CSS file

Answer: A) In the ViewModel

Explanation:

The Button binds its Command property to SaveCommand. In MVVM, the command is normally exposed by the ViewModel so that the View can invoke the corresponding operation.

48. Consider an ObservableCollection<Product> bound to a ListView. A product is added using the collection's Add method. What allows the bound control to detect the collection change?

  1. ObservableCollection's collection-change notification
  2. INotifyPropertyChanged on the View class only
  3. The Model's database connection
  4. The XAML compiler restarting the application

Answer: A) ObservableCollection's collection-change notification

Explanation:

ObservableCollection<T> implements INotifyCollectionChanged and raises collection-change notifications when items are added or removed, allowing bound controls to update.

49. A ViewModel exposes a SubmitCommand and an IsFormValid property. The command should execute only when the form is valid. Which design is most appropriate?

  1. Use the command's CanExecute logic based on IsFormValid
  2. Disable the database server when the form is invalid
  3. Put all validation logic inside the Button's visual template
  4. Make SubmitCommand a static database connection

Answer: A) Use the command's CanExecute logic based on IsFormValid

Explanation:

The command can use CanExecute to determine whether submission is currently allowed. When IsFormValid changes, the command can notify consumers so the UI can reevaluate its enabled state.

50. Consider this MVVM flow: a user changes a value in the View, the bound ViewModel property is updated, the ViewModel recalculates a dependent property, and the View should display the new dependent value. What is required for the final UI update?

  1. The ViewModel should raise property-change notification for the dependent property
  2. The Model must recreate the View
  3. The View must be manually rebuilt after every keystroke
  4. The application must restart its binding engine

Answer: A) The ViewModel should raise property-change notification for the dependent property

Explanation:

If the View is bound to a calculated property, changing one of its inputs does not by itself guarantee that the binding system knows the calculated property changed. The ViewModel should raise PropertyChanged for the dependent property so the View can retrieve and display its new value.

Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2026 www.includehelp.com. All rights reserved.