Xamarin Certification Xamarin Data and Services 1 — Questions and Answers
Question 1: Which NuGet package provides SQLite database access in Xamarin cross-platform apps?
- sqlite-net-pcl (Correct answer)
- System.Data.SQLite
- EntityFrameworkCore.Sqlite
- Mono.Data.Sqlite
Correct answer: sqlite-net-pcl
sqlite-net-pcl (SQLite-Net) is the standard lightweight ORM for SQLite in Xamarin, supporting iOS and Android via a single PCL/NuGet.
Question 2: In Xamarin, which HttpClient handler is recommended for best performance on iOS?
- NSUrlSessionHandler (Correct answer)
- HttpClientHandler
- ModernHttpClient
- CFNetworkHandler
Correct answer: NSUrlSessionHandler
NSUrlSessionHandler uses the native iOS networking stack, providing better performance, TLS support, and HTTP/2 compared to the managed handler.
Question 3: What is the recommended way to make HTTP REST calls in shared Xamarin code?
- System.Net.Http.HttpClient (Correct answer)
- NSURLConnection
- OkHttp
- WebClient
Correct answer: System.Net.Http.HttpClient
HttpClient from System.Net.Http is the cross-platform HTTP client available in .NET Standard and works in shared Xamarin code.
Question 4: Which Xamarin.Essentials API provides cross-platform access to the device's network connectivity status?
- Connectivity (Correct answer)
- NetworkInfo
- Reachability
- NetworkAccess
Correct answer: Connectivity
Xamarin.Essentials Connectivity class exposes NetworkAccess and ConnectionProfiles to check current network state cross-platform.
Question 5: In Xamarin, which pattern ensures HTTP API calls do not block the main thread?
- async/await with Task-returning methods (Correct answer)
- Thread.Start with callbacks
- BackgroundWorker
- Parallel.For
Correct answer: async/await with Task-returning methods
Using async/await with HttpClient.GetAsync and similar Task-returning methods ensures network I/O is non-blocking and the UI remains responsive.
Question 6: Which library is commonly used for JSON serialization and deserialization in Xamarin applications?
- Newtonsoft.Json (Json.NET) (Correct answer)
- System.Xml.Serialization
- Google.Gson
- Codable
Correct answer: Newtonsoft.Json (Json.NET)
Newtonsoft.Json (Json.NET) is the most widely used .NET JSON library and works seamlessly in Xamarin shared and platform code.
Which NuGet package provides SQLite database access in Xamarin cross-platform apps?