Xamarin Certification Xamarin Cross-Platform Architecture 1 — Questions and Answers
Question 1: What is the Shared Project approach in Xamarin cross-platform development?
- Source files shared across platform projects at compile time with no output assembly (Correct answer)
- A NuGet package containing shared code
- A runtime abstraction layer
- A Git submodule strategy
Correct answer: Source files shared across platform projects at compile time with no output assembly
A Shared Project contains source files included directly in each referencing platform project at compile time, producing no separate DLL.
Question 2: What is a Portable Class Library (PCL) in Xamarin development?
- A compiled library targeting a common API subset usable across multiple platforms (Correct answer)
- A shared project with platform directives
- A NuGet-only distribution format
- An Android-specific class library
Correct answer: A compiled library targeting a common API subset usable across multiple platforms
A PCL compiles to a DLL targeting a specific API intersection (profile) supported by the selected platforms.
Question 3: Which .NET project type replaced PCL as the preferred Xamarin shared library format?
- .NET Standard Library (Correct answer)
- Shared Project
- Class Library (net6)
- Universal Library
Correct answer: .NET Standard Library
.NET Standard Libraries define a versioned API surface supported across all .NET implementations, replacing PCL profiles.
Question 4: In Xamarin cross-platform development, what is the Dependency Service used for?
- Resolving platform-specific implementations from shared code (Correct answer)
- Injecting database services
- Managing HTTP dependencies
- Registering NuGet packages at runtime
Correct answer: Resolving platform-specific implementations from shared code
DependencyService allows shared code to call platform-specific implementations registered with [assembly: Dependency] attributes.
Question 5: What design pattern is recommended for separating UI logic from business logic in Xamarin applications?
- MVVM (Model-View-ViewModel) (Correct answer)
- MVC (Model-View-Controller)
- MVP (Model-View-Presenter)
- VIPER
Correct answer: MVVM (Model-View-ViewModel)
MVVM is the recommended pattern for Xamarin, where ViewModels expose data via bindings and commands, keeping UI logic testable.
Question 6: Which interface must a ViewModel implement to notify the View of property changes in Xamarin MVVM?
- INotifyPropertyChanged (Correct answer)
- IObservable
- IDataBinding
- IViewModel
Correct answer: INotifyPropertyChanged
INotifyPropertyChanged exposes the PropertyChanged event that the binding engine listens to for automatic UI updates.
What is the Shared Project approach in Xamarin cross-platform development?