Xamarin Interview Questions and Answers
Question - 31 : - What is the need of the Model-View-ViewModel (MVVM ) pattern in Xamarin?
Answer - 31 : -
The Model-View-ViewModel can be used on all platforms. It intends to provide a clean separation between the user interface controls and their logic.
Benefits:
- During the development process, developers and designers can work independently on their components. Designers can concentrate on the view, and if they are using Expression Blend, they can generate sample data. On the other hand, developers can work on the view model and model components.
- Developers create the unit tests for the view model and can create the model for the view.
- It is easy to redesign the UI of the application without touching the code because the view is implemented entirely in XAML. A new version of the view should work with the existing view model.
- If there is any existing representation of the model that binds the existing business logic, this can be difficult or risky to change. In this scenario, the view model acts as an adapter for the model classes and enable us to avoid making any major changes to the code of the model.
Question - 32 : - What is Fresh MVVM?
Answer - 32 : -
Fresh MVVM is a super light MVVM framework which is designed specifically for Xamarin.Forms only. Its design is easy, simple, and flexible. It is easy to learn and uses the convention over configuration.
Fresh MVVM is a little different from MVVM. FreshMvvm uses the concept of Page and PageModel instead of View and ViewModel.
Question - 33 : - How Xamarin.Android applications work?
Answer - 33 : -
Xamarin.Android applications depend on Microsoft's Mono Virtual Machine. Mono is Microsoft's open-source implementation of the .Net Framework, which is based on open source standards of C# and CLR. Mono was launched in the year 2001. It was created to allow the .Net applications to work on the Linux platform, but was later modified to support the development on various devices, including embedded systems.
In Xamarin, Mono works in parallel with Android's ART. On Android, most of the system facilities like Audio, Graphics, OpenGL, and Telephony are not available directly to the native applications. They can be added through the Android Runtime Java APIs, which is available in one of the Java.*namespaces or the Android.*namespaces. The native applications then interact with the exposed .NET APIs. These APIs then, through the Android Binding, call the Android runtime Java APIs.
The architecture looks like this:
Question - 34 : - Name the apps that were designed by Xamarin for iOS?
Answer - 34 : -
The apps that were designed by Xamarin for iOS are:
- QuickPLan- Project Plan HD
- NewsPager
- Apocalyspe Archer: Zombie invasion
- Stone Skimmer: Skimming action game
Question - 35 : - What are the apps designed by Xamarin for Android?
Answer - 35 : -
The apps designed by Xamarin for Android are:
- The secret society
- Parental Access
- Toolwiz cleaner
- iLearnForKids
- Goal 2014 Football manager
Question - 36 : - What is the lifecycle method of the Xamarin.Forms App?
Answer - 36 : -
Lifecycle methods are the set of techniques which are executed when the application enters into a specific state. The ways are:
- OnStart: This method will run when the application starts from the beginning.
- OnSleep: This method will execute when the application goes into the background.
- OnResume: This method will execute when the application comes in the foreground from the sleeping state.
Question - 37 : - What is the purpose of XAML compiler (XALC)?
Answer - 37 : -
Using the XAML compiler, we can directly compile XAMLs into intermediate (IL) language.
Benefits:
- It performs the compile-time checking to find the error in XAML. At compile time it notifies the user about any mistake.
- It removes the overheads and initialization time for XAML elements.
- It doesn't include the XAML file into the final assembly, and thus it reduces the assembly time.
Question - 38 : - What is XAML namespace declaration?
Answer - 38 : -
XAML namespace is the declaration of the namespaces on top of the XAML file. There are two declarations available within the root element when we create any new XAML UI. Here is the default declaration of the xmlns without any prefix:
xmlns="http://xamarin.com/schemas/2014/forms"
The second declaration uses the x prefix:
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
All declaration of the namespace which uses the prefix is a non-default declaration.
Suppose we want to bind the ViewModel with XAML and that ViewModel is declared inside the namespace, "XamSample.ViewModels".
xmlns:vm="clr-namespace:XamSample.ViewModels; assembly=XamSample.ViewModels"
Then we can access the element from inside this namespace using VM prefix.
Question - 39 : - What is the way of navigation from one page to another?
Answer - 39 : -
After clicking on the button of the first page, we call the following method through which we can navigate from one page to another page.
await Navigation.PushAsync(new MySecondPageXaml(), true);
We have to use the "Navigation" page property which is available under the ContentPage class. This code is written in the coding page of the MainPage.XAML file.
Question - 40 : - What is ViewCell?
Answer - 40 : -
A ViewCell is a small individual element which represents a single item of the ListView or Table. A ViewCell is not a visual element, but it is a description of the template which creates the visual aspect.