Introduction
.NET framework is a software-based framework developed by Microsoft primarily to run on windows. .NET can be used for building, deploying, and executing applications that use .NET technologies such as desktop and web-based applications.
This article will help you understand more about .NET by discussing the various .net interview questions to brush up on your knowledge before the interview.
Must Recommended Topic, Pandas Interview Questions and Operating System Interview Questions
.NET Interview Questions
Question 1) What programming languages does the .NET framework support?
Answer 1) The .Net framework supports many programming languages such as Microsoft and non-Microsoft languages. The most popular programming languages supported by .NET are C#, C++, VB, Perl, Cobol, F#, and JavaScript.
Question 2) What is the .NET framework?
Answer 2) The .NET is a software framework developed by Microsoft Corporation for Windows-based applications. .NET can also be used for creating both web and mobile-based applications. It is a complete system of libraries, classes, and APIs that can support the building and deployment of applications.
.NET framework contains the following parts:
- Common Language Runtime
- Framework classes
- ASP.NET
Question 3) What is CTS?
Answer 3) CTS, or the Common Type System, contains a set of rules that state how a data type should be declared, defined, and used while programming. CTS helps describe the data type that is to be used in an application.
With CTS, it is possible to design 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 can be called by an application that is developed using a different language.
Question 4) What is CLR?
Answer 4) CLR or the Common Language Runtime is one of the essential components of the .Net framework as it provides the building blocks for many applications.
An application that is built using C# when compiled by its compiler, is converted into the Intermediate language. This Intermediate language is then targeted to the CLR. The CLR then performs various operations such as security checks, memory management, assemblies to be loaded, and thread management. CLR also provides a secure environment for an application's execution.
Question 5) What is CLS?
Answer 5) CLS or the Common Language Specification is a subset of the CTS (Common Type System). The CLS is essentially a set of rules for programming languages that the .NET framework must follow. CLS helps turn a program into CIL (Common Intermediate Language) code so that it is possible to write different parts of a program in different languages. Hence, the CLS allows seamless communication between other .NET compatible languages.
Question 6) What is the use of JIT in the .NET framework?
Answer 6) JIT, also called the just-in-time compiler, is used for executing a program. After converting the source code into an intermediate language, we need to convert this intermediate language into the machine code. The JIT compiler helps with this task. Therefore, the JIT compiler is called so as it converts an intermediate language into machine code whenever required instead of converting the entire code all at once.
Question 7) What is a managed code? How does it differ from an unmanaged code?
Answer 7) A managed code is one that performs in a controlled runtime environment. For example, consider where a code is executed by the CLR (Common Language Runtime) in the .NET framework is called a managed code. Here a controlled runtime environment automatically manages and executes the code by providing many services such as garbage collection, memory allocation, and exception handling. In contrast, unmanaged code performs in an independent environment.
Question 8) Explain the garbage collection process.
Answer 8) The CLR (Common Language Runtime) contains a garbage collector which allocates and releases memory for an application automatically. When the CLR has initialized, the garbage collector allocates memory for the objects. This memory segment is called a managed heap. This managed heap is organized into three generations 0, 1, and 2. Generation 0 is used for short-lived objects, and the garbage collector releases the code objects in this heap more often than Generations 1 and 2.
Question 9) What are the different versions of the .NET framework?
Answer 9)
Version | .NET Framework | Visual Studio |
C# 1.0 | .NET Framework 1.0/1.1 | Visual Studio .NET 2002 |
C# 2.0 | .NET Framework 2.0 | Visual Studio 2005 |
C# 3.0 | .NET Framework 3.0/3.5 | Visual Studio 2008 |
C# 4.0 | .NET Framework 4.0 | Visual Studio 2010 |
C# 5.0 | .NET Framework 4.5 | Visual Studio 2012/2013 |
C# 6.0 | .NET Framework 4.6 | Visual Studio 2013/2015 |
C# 7.0 | .NET CORE | Visual Studio 2017 |
Question 10) What is the difference between a Hash table and an Array list?
Answer 10) The Hash table is used to store data in the form of value pair and name, while the Array list is used to store values only.
It is required to pass the name to access values from the Hash table, whereas, in an Array, it is necessary to give the index number to access a value.
Question 11) List the advantages of using the session?
Answer 11) The advantages of using a session are as follows:
- It is secure and transparent for users as the session object is stored on the server.
- It stores the user data and states all over the application.
- It is very effortless to use and can store any kind of object.
- It is capable of storing each user's data separately.
Question 12) List the disadvantages of using the session?
Answer 12) The disadvantages of using sessions are as follows:
in the case of a large number of users, Performance overhead can occur as the session data is stored in server memory.
There is an Overhead involved in serializing and De-Serializing session Data. Due to the case of StateServer and SQLServer session mode, we need to serialize the object before storing them.
Question 13) What are MDI and SDI?
Answer 13) The MDI or the Multiple Document Interface allows one to open multiple windows. These windows will have one parent window that has many child windows. The components in MDI are shared from the parent window.
The SDI or the Single Document Interface) opens each document in a separate window. Here each window has its components. Hence SDI is not constrained to the parent window like the MDI.
Question 14) What is caching?
Answer 14) Caching is a technique used for storing data temporarily in the memory in order to access the data from memory instead of searching the original location for it. Caching dramatically increases the efficiency of an application and its speed.
Question 15) Explain CAS?
Answer 15) CAS, or code access security is a part of the security model that prevents unauthorized access to resources. CAS enables a user to set permissions for the code. CLR can then executes the code depending upon the permissions.CAS can be used for managed code only.
Question 16) What is a delegate in .NET?
Answer 16) A delegate is similar to a function pointer used in other programming languages such as C++. A delegate permits a user to encapsulate a reference of a method in a delegate object which can then be passed into a program. This program will then call the referenced method.
Question 17) What are the memory-mapped files?
Answer 17) The Memory-mapped files are used to map out the content inside a file to a logical address of an application. These mapped files make it possible to run multiple processes on the same machine and to share data with each other.
Question 18) Which method is used to enforce garbage collection in .NET?
Answer 18) The System.GC.Collect() method is used to enforce garbage collection in .NET
Question 19) What is an assembly?
Answer 19) An assembly is a file that is generated by the compiler automatically. Thus files consist of a collection of types and resources that are created to work together and form a logical unit. In other words, an assembly is simply a compiled code or a logical unit of code.
Question 20) Is ASP.NET different from ASP? If yes, explain how?
Answer 20) Yes! The ASP.NET and ASP(Active Server Pages)are both different.
- The ASP.NET can use .NET languages such as C# and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL).
- ASP uses the VBScript, and its code is interpreted during the execution.
- ASP.NET is developed by Microsoft and is used to create dynamic web-based applications, while the ASP is Microsoft's server-side technology designed to create web pages.
- ASP.NET is fully object-oriented, whereas ASP is partially object-oriented.
- ASP.NET has full XML Support for effortless data exchange, whereas ASP has no support for XML.
Question 21) What is boxing and unboxing in .NET?
Answer 21) Boxing is the process of direct conversion of a value type into a reference type. Whereas, Unboxing is the reverse of Boxing, meaning a process where a reference type is converted back into a value type.
Consider an example given below:
int container = 55; // This is a value type
object o = container; // This is boxing
int contain = (int)o; // This is unboxing
Question 22) What is the appSettings section in the web.config file?
Answer 22) The appSettings block in the web.config file can be used in case we want to set the user-defined values for the whole application.
Consider the example below:
<em>
<configuration>
<appSettings>
<add key= "Connection" value="server=local; pwd=password; database=default" />
</appSettings>
</configuration>
</em>
Here Connection will be used for the database connection throughout the project.
Question 23) What are the types of memories supported in the .NET framework?
Answer 23) There are two types of memories supported by the .NET framework:
- Stack
- Heap
Question 24) What are the different types of indexes in .Net?
Answer 24) There are two types of indexes in .Net:
- Clustered index
- Non-clustered index
Question 25) Explain cookies?
Answer 25) Cookies are small chunks of data created by the server on the client-side. When a web server creates a cookie, an additional HTTP header is sent to the browser.
Question 26) Explain CAS?
Answer 26) CAS, or code access security is a part of the security model that prevents unauthorized access to resources. CAS enables a user to set permissions for the code. CLR can then executes the code depending upon the permissions.CAS can be used for managed code only.
Question 27) What is an IL?
Answer 27) An IL or the Intermediate Language is also known as MSIL (Microsoft Intermediate Language). A .NET source code is first compiled to an Intermediate Language or IL. Then the IL is converted to the machine code.
Question 28) What are tuples in .Net?
Answer 28) A tuple is a fixed-size collection that is capable of having elements of either the same or different data types. A user must have to mention the size of a tuple at the time of declaration, similar to an array.
Question 29) What do you mean by AutoPostBack?
Answer 29) AutoPostBack is a property that is used to automatically postback whenever an event is triggered. The AutoPostBack property has to be set to True.
Question 30) What is cross-page posting?
Answer 30) When a user clicks on the submit button of a webpage, the data is stored on the same page. However, when the data is stored on a different page, it is called cross-page posting. It can be achieved by using the POSTBACKURL property, which allows the postback functionality.
Question 31) Explain passport authentication.
Answer 31) The passport authentication cookies are checked first during a passport authentication. In case the cookie is not available, the application will redirect to the passport sign-on page. The passport service then authenticates every detail of a user on the sign-in page, and if they are valid, it stores them on the client machine.
Question 32) List various parameters that control most of the connection pooling behaviors?
Answer 32) The following are the parameters that control the connection pooling behavior:
- Max Pool Size
- Min Pool Size
- Connect Timeout
- Pooling
Question 33) Describe the EXE and DLL modules.
Answer 33) The EXE is an executable file that is used to run an application. A system generates an EXE file automatically when the application is built. DLL or the dynamic link library used for storing hidden codes. It is possible for an application to have multiple DLLs.