Top 20 Latest .Net Interview Questions & Answers. .Net is the most widely used framework for developing applications on windows. It encompasses ASP .Net, languages such as C#, VB .Net, Perl, Cobol, etc.
And in one article it won’t be possible to cover all of the vast .Net concepts. Therefore the following section consists only of questions relating to the. Net framework and its core. For more questions on. Net C#, please refer to the questions on the C# interview.
.Net Interview Questions & Answers
This article will enlist the top 20 most popular .Net interview questions and answers in simple terms along with examples for your easy understanding.
Most Popular .Net Interview Questions and Answers
Here is the list of the most popular .Net interview questions and answers.
Q.No: 1) What is the .Net framework?
Ans: It is a platform for building various applications on windows. It has a list of inbuilt functionalities in the form of class, library, and APIs which are used to build, deploy and run web services and different applications. It supports different languages such as C#, VB .Net, Cobol, Perl, etc.
This framework supports the object-oriented programming model.
Q.No: 2) What are the important components of .Net?
Ans: The components of .Net are Common language run-time, .Net Class library, Application domain, Common Type System, .Net framework, Profiling, etc. However, the two important components are the Class library and the Common Language Runtime.
CLR provides building blocks for a wide variety of applications. The class library consists of a set of classes that are used to access common functionality. The functionality can be shared among different applications.
Q.No: 3) What is CTS?
Ans: CTS stands for Common Type System. It has a set of rules which state how a data type should be declared, defined and used in the program. It describes the data types that are to be used in the application.
We can design our own classes and values by following the rules that are present in the CTS. The rules are made so that the data type declared using a programming language is callable by an application that is developed using a different language.
Q.No: 4) What is CLR?
Ans: CLR stands for Common Language Runtime. It is one of the most important components of the .Net framework. It provides building blocks for many applications.
An application built using C# gets compiled by its own compiler and is converted into an Intermediate language. This is then targeted to CLR. CLR does various operations like memory management, Security checks, assemblies to be loaded and thread management. It provides a secure execution environment for applications.
Q.No: 5) What is CLS?
Ans: CLS stands for Common Language Specification. With the rules mentioned under CLS, the developers are made to use the components that are inter-language compatible. They are reusable across all the .Net Compliant languages.
Q.No: 6) What is JIT?
Ans: JIT stands for Just In Time. JIT is a compiler that converts Intermediate Language to Native code.
The code is converted into the Native language during execution. Native code is nothing but hardware specifications that can be read by the CPU. The native code can be stored so that it is accessible for subsequent calls.
Q.No: 7) What is MSIL?
Ans: MSIL stands for Microsoft Intermediate Language.
MSIL provides instructions for calling methods, initializing and storing values, operations such as memory handling, exception handling and so on. All .Net codes are first compiled to IL.
Q.No: 8) What is meant by the Managed and Unmanaged code?
Ans: The code that is managed by the CLR is called Managed code. This code runs inside the CLR. Hence, it is necessary to install the .Net framework in order to execute the managed code. CLR manages the memory through garbage collection and also uses the other features like CAS and CTS for efficient management of the code.
Unmanaged code is any code that does not depend on CLR for execution. It means it is developed by any other language independent of the .Net framework. It uses its own runtime environment for compiling and execution.
Though it is not running inside the CLR, the unmanaged code will work properly if all the other parameters are correctly followed.
Q.No: 9) How is a Managed code executed?
Ans: Following steps are followed while executing a Managed code:
Choosing a language compiler depending on the language in which the code is written.
Converting the above code into Intermediate Language by its own compiler.
The IL is then targeted to CLR which converts the code into native code with the help of JIT.
Execution of Native code.
Q #10) What is ASP.Net?
Ans: ASP .Net is a part of .Net technology and it comprises of CLR too. It is an open-source server-side technology that enables the programmers to build powerful web services, websites and web applications.
ASP stands for Active Server Pages.
Q.No: 11) Explain State management in ASP .Net?
Ans: State Management means maintaining the state of the object. The object here refers to a web page/control.
There are two types of State management, Client Side, and Server side.
Client-Side – Storing the information in the Page or Client’s System. They are reusable, simple objects.
Server Side – Storing the information on the Server. It is easier to maintain the information on the Server rather than depending on the client for preserving the state.
Q.No: 12) What is an Assembly? What are the different types of Assemblies?
Ans: An Assembly is a collection of logical units. Logical units refer to the types and resources which are required to build an application and deploy them using the .Net framework. The CLR uses this information for type implementations. Basically, Assembly is a collection of Exe and DLLs. It is portable and executable.
There are two types of Assemblies, Private and Shared.
Private Assembly, as the name itself suggests, it is accessible only to the application. It is installed in the installation directory of the Application.
A Shared assembly can be shared by multiple applications. It is installed in the GAC.
Q.No: 13) Explain the different parts of an Assembly.
Ans: The different parts of an Assembly are:
- Manifest – It contains information about the version of an assembly. It is also called as assembly metadata.
- Type Metadata – Binary information of the program.
- MSIL – Microsoft Intermediate Language code.
- Resources – List of related files.
Q.No: 14) What is an EXE and a DLL?
Ans: Exe and DLLs are Assembly executable modules.
- Exe is an executable file. This runs the application for which it is designed. An Exe is generated when we build an application. Hence the assemblies are loaded directly when we run an Exe. However, an Exe cannot be shared with the other applications.
- DLL stands for Dynamic Link Library. It is a library that consists of code that needs to be hidden. The code is encapsulated inside this library. An Application can consist of many DLLs. These can be shared with the other applications as well.
- Other applications that need to share this DLL need not worry about the code intricacies as long as it is able to call the function on this DLL.
Q.No: 15) What is Caching?
Ans: Caching means storing data temporarily in the memory so that the application can access the data from the cache instead of looking for its original location. This increases the performance of the application and its speed. System.Runtime.Caching namespace is used for Caching information in .Net.
Given below are the 3 different types of Caching:
- Page Caching
- Data Caching
- Fragment Caching
Q.No: 16) What is MVC?
Ans: MVC stands for Model View Controller. It is an architectural model for building the .Net applications.
Models – Model objects store and retrieve data from the database for an application. They are usually the logical parts of an application that is implemented by the application’s data domain.
View – These are the components that display the view of the application in the form of UI. The view gets the information from the model objects for their display. They have components like buttons, drop boxes, combo box, etc.
Controllers – They handle the User Interactions. They are responsible for responding to the user inputs, work with the model objects, and pick a view to be rendered to the user.
Q.No: 17) What is the difference between Function and Stored procedure?
Ans: Stored Procedure:
- A Stored procedure is always used to perform a specific task.
- It can return zero, one or more value.
- It can have both Input and Output Parameters.
- Exception handling can be done using a try-catch block.
- A function can be called from a Procedure.
- Functions must return a single value.
- It can only have the input parameter.
- Exception handling cannot be done using a try-catch block.
- A Stored procedure cannot be called from a function.
Q.No: 18) Explain CAS (Code Access Security)?
Ans: .Net provides a security model that prevents unauthorized access to resources. CAS is a part of that security model. CAS is present in the CLR. It enables the users to set permissions at a granular level for the code.
CLR then executes the code depending on the available permissions. CAS can be applied only to the managed code. Unmanaged code runs without CAS. If CAS is used on assemblies, then the assembly is treated as partially trusted. Such assemblies must undergo checks every time when it tries to access a resource.
The different components of CAS are Code group, Permissions, and Evidence.
Evidence– To decide what permissions to give, the CAS and CLR depend on the specified evidence by the assembly. The examination of the assembly provides details about the different pieces of evidence. Some common evidence includes Zone, URL, Site, Hash Value, Publisher and Application directory.
Code Group – Depending on the evidence, codes are put into different groups. Each group has specific conditions attached to it. Any assembly that matches those conditions is put into that group.
Permissions – Each code group can perform only specific actions. They are called Permissions. When CLR loads an assembly, it matches them to one of the code groups and identifies what actions those assemblies can do. Some of the Permissions include Full Trust, Everything, Nothing, Execution, Skip Verification, and the Internet.
Q.No: 19) What is GAC?
Ans: GAC stands for Global Assembly Cache. Whenever CLR gets installed on the machine, GAC comes as a part of it. GAC specifically stores those assemblies which will be shared by many applications. A Developer tool called Gacutil.exe is used to add any file to GAC.
Q.No: 20) What is meant by Globalization and Localization?
Ans: Internationalization is the process of designing applications that support multiple languages. This is divided into Localization and Globalization.
Globalization is nothing but developing applications to support different languages. Existing applications can also be converted to support multiple cultures.
Whereas Localization means changing the already globalized app to cater to a specific culture or language Microsoft.Extensions.Localization is used for localizing the app content. Some of the other keywords that are used for Localization are IHtmlLocalizer, IStringLocalizer, IViewLocalizer and so on…