Xamarin Certification Xamarin.Android Development 2 — Questions and Answers
Question 1: Which Xamarin.Android control displays a scrollable list of items using view recycling?
- RecyclerView (Correct answer)
- ListView
- UITableView
- DataGrid
Correct answer: RecyclerView
RecyclerView is the modern Android list control that recycles view holders for efficient scrolling.
Question 2: In Xamarin.Android, how do you request a runtime permission (Android 6.0+)?
- RequestPermissions
- ActivityCompat.RequestPermissions (Correct answer)
- PermissionManager.Request
- AskPermission
Correct answer: ActivityCompat.RequestPermissions
ActivityCompat.RequestPermissions is the backward-compatible method to request permissions at runtime.
Question 3: What is the purpose of the AndroidManifest.xml in Xamarin.Android?
- Declares app components, permissions, and metadata (Correct answer)
- Stores string resources
- Defines UI layouts
- Contains database schemas
Correct answer: Declares app components, permissions, and metadata
AndroidManifest.xml is the app's configuration file declaring activities, services, permissions, and min SDK version.
Question 4: Which lifecycle method should you override to save Activity state before it is destroyed?
- OnSaveInstanceState (Correct answer)
- OnPause
- OnStop
- OnDestroy
Correct answer: OnSaveInstanceState
OnSaveInstanceState provides a Bundle to save transient UI state that can be restored in OnCreate.
Question 5: In Xamarin.Android, which class is used to run background tasks that survive Activity recreation?
- ViewModel (Correct answer)
- AsyncTask
- Thread
- Service
Correct answer: ViewModel
ViewModel (from AndroidX) stores UI-related data that survives configuration changes like screen rotation.
Question 6: What is D8 in the context of Xamarin.Android builds?
- The DEX compiler that converts .NET IL to Dalvik bytecode (Correct answer)
- A debug tool for GPU rendering
- An ADB command
- A layout inspector tool
Correct answer: The DEX compiler that converts .NET IL to Dalvik bytecode
D8 is the dexer used by Xamarin.Android to compile managed IL into DEX bytecode for the Android runtime.
Which Xamarin.Android control displays a scrollable list of items using view recycling?