These .NET questions have been designed for various interviews, competitive exams and entrance tests. We have covered questions on both basic and advanced concepts which will help you improve your skills to face interview questions on .NET.
Who is this .NET interview questions designed for?
All the Programmers, Software Engineers, Web developers, Front End developers, UI/ UX developers and designers will find these questions extremely useful. All freshers, BCA, BE, BTech, MCA and college students wanting to make a career in front end designing will be highly benefitted by these questions.
.NET interview questions topics
This section covers .NET topics like - .Net Framework, Components of .Net Framework, .Net Assembly, GAC in the .Net Framework, Web.Config and Machine.Config etc.
1. What is the .Net Framework?
.Net framework is a software development platform for building various applications on Microsoft windows.
It contains inbuilt functionalities in the form of class, library, and APIs that are used to develop applications for web, Windows, phone.
It supports various programming languages such as C#, VB .Net, Cobol, Perl, etc. So, the developer can choose the language to develop software.
It provides various services to the application like memory management, version compatibility, security, type-safety, language interoperability etc.
2. What are the two major components of .Net Framework?
The two major components of .NET Framework are the Common Language Runtime and the .NET Framework Class Library.
Common Language Runtime (CLR) - It manages the execution of .NET programs. It works as a layer between operating systems and the applications written in .Net languages. It makes the development process easier by providing services like Memory management, Thread execution, Type safety, Exception Handling, Security etc.
.Net Framework Class Library (FCL) - It includes collection of classes, namespaces, interfaces and value types that are used for .NET applications to access common functionality.
3. What is .Net Assembly?
An assembly is a smallest unit of deployment in a Microsoft .NET Framework application. It can be implemented as .exe or .dll files. It provides all required execution information to common language runtime. The .Net Framework maintains multiple versions of the application in the system through assembly.
An assembly is made up of the following four different types of components:
Assembly manifest - It contains information about the version of the assembly
Type metadata - It contains binary information of the program.
MSIL source code - Microsoft Intermediate Language (MSIL) is a CPU-independent set of instructions that can be efficiently converted to the native code.
Resources - All other related files like icons, images etc.
4. What are the different types of assemblies?
The following are the two types of assemblies:
Private Assembly
Shared Assembly
Private Assembly is used by a single application. It is kept in a local folder in which the client application has been installed.
Public or Shared Assembly is allowed to be shared by multiple applications. A shared assembly must reside in Global Assembly Cache (GAC) with a strong name assigned to it.
5. Describe GAC in the .Net Framework
GAC stands for global assembly cache. It is an area of memory reserved to store assemblies of all .NET applications that are running on a machine. It stores those assemblies which will be shared by many applications.
6. What is a Satellite assembly?
Satellite assemblies provide an application the multilingual support. They include localized resources for an application.
Using satellite assemblies, you can include resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user selects to view the application in that language.
7. Explain the difference between dataset and datareader.
Dataset is a disconnected architecture. We don't require active database connection while working with Dataset. DataReader is a connection oriented service; the data is available as long as the connection with database exists.
DataSet is an in-memory representation of a collection of Database objects. It is like is a small database because it stores the schema and data in the application memory area. Datareader provides forward-only and read-only access to data from data sources. It is like a forward only recordset.
DataSet can be serialized and represented in XML, so it can easily pass around to other tiers. DataReader can't be serialized.
DataSet is updatable, we can make changes to the data and send those changes back to the data source. Dataset is best choice where we want manipulation of data. DataReader is read-only we can’t make changes to the data. DataReader is best choice where we require no manipulation.
8. What is the difference between Web.Config and Machine.Config?
The machine.Config file is the master configuration file on your system and is the default configuration for all applications running on that machine. This is automatically installed when you install Visual Studio .Net. We can have only one machine.config file on a server.
The Web.Config is an application level configuration file which is automatically created when you create an ASP.Net web application project. It is a file that manages various settings for a website. It stores configuration data in XML format. Generally a website contains a single Web.config file, but we can have many configuration files that manage settings at various levels within an application.
9. What do you understand by side-by-side execution of assembly?
Side-by-side execution allows assemblies to coexist and execute multiple versions of same assembly simultaneously on the same computer.
10. What is MVC?
MVC stands for Model, View and Controller. MVC is a software architectural pattern which separates the representation and user interaction.
Model represents the real world object and provides data to the view. It is nothing but a set of classes that describes business logic.
View is responsible for look and feel. It represents UI components like HTML, CSS, jQuery etc.
Controller is responsible for taking the end user request via View and loading the appropriate Model and View.
11. Why do we need .Net Web Services?
We have a number of heterogeneous technologies available on internet. The demand for reusable components across platforms and programming languages are high. Most of the components have the limitation that they can't share or exchange data across different platforms, they are mostly language specific or platform specific. The technologies like COM, RMI, CORBA etc. contributed best to fulfill requirements to some extent, but components result from these said technologies are mostly either language specific or platform specific.
To avoid above problem, we need to have web services. Through web services we have overcome the problem of interoperability between languages and platforms. Web services uses SOAP as transport protocol which uses a text based messaging model, i.e. XML to communicate between disparate systems.
12. Explain the situation you will use a Web Service and Remoting in projects.
Both .Net Web services and .Net Remoting are Microsoft solutions for distributed solution.
A web service allows communication between applications over the World Wide Web. It is a simple programming model with broad cross-platform reach. It supports heterogeneous environment which means client and remote object can be built in any platform. Web services should be used if the application demands communication over a public network and require to work across multiple platforms.
.NET Remoting allows objects to interact with each other across application domains. It supports homogeneous environment that requires the client be built using .NET. It allows high speed communication between a client application and components in a binary format. .NET Remoting is good choice when we want to establish communication between proprietary .NET components, usually over an internal network.
13. What is garbage collection? Is it possible to force garbage collection to run?
Garbage collection is a .Net feature that manages the memory for applications by allocating and releasing memory automatically.
When the garbage collector performs a collection, it identifies objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their memory.
Yes, System.GC.Collect() forces garbage collector to run. It can be used to invoke the garbage collector to perform cleanup processing. However, it is not guaranteed that the Garbage Collection process will start after calling the method.
14. Why do we need serialization in .NET?
Serialization is the process of converting an object into a stream of bytes to persist the object's state into the memory, a database, or a file. The reverse of serialization is deserialization. Serialization facilitates the transmission of an object over a network.
Remoting applications depend heavily on Serialization and De-serialization.
15. What is meant by Managed and Unmanaged code?
Managed code is a code whose execution is managed by Common Language Runtime. This code runs inside the CLR. Hence, it is necessary to install the .Net Framework in order to execute the managed code.
Unmanaged code is any code that does not depend on CLR for execution and is not under the control of the CLR. It means it is developed by any other language independent of .Net Framework. It uses its own runtime environment for compiling and execution.