TOP-10 Interview Questions in .NET - ByteScout
  • Home
  • /
  • Blog
  • /
  • TOP-10 Interview Questions in .NET

TOP-10 Interview Questions in .NET

This article contains common .NET interview questions and answers that can help you land the position and test your knowledge of the framework.

Interview Questions in .NET

Q1. What is.NET framework?

Answer: It is a software framework developed by Microsoft, which is used to create and run a wide range of software applications on windows. It supports various languages like C#, VB, Cobol, Perl, .NET, etc. With the help of. NET developers can work on both form- and web-based applications and services. The wide variety of tools and functions such as class, libraries, and APIs help build, deploy, and run different applications and web services.

Q2. What are the essential components of .NET?

Answer: The two most essential components of the .NET framework is the Common Language Runtime(CLR) and Class library.

Some Other components are Common language runtime, .Net Class library, Application domain, Common Type System, .Net framework, Profiling, etc.

CLR provides various building tools and resources that help the developers set the foundation of building an application.

The class library holds essential classes that provide commonly known functionality that is shareable across applications.

Q3. What makes it possible for the .NET framework to support different languages?

Answer: The reason behind the .net framework to be multilingual is that its compilers convert the source code into Microsoft Intermediate Language (MSIL). The code is compiled from IL and is interoperable with the code from another language. So after compilation, the language doesn’t remain a barrier, and the code can also call or use functions of another language.

Q4. What do you mean by managed and unmanaged code?

Answer: Managed code: the codes whose execution is managed by Common Language Runtime. It receives the managed code and compiles it into the machine code that is then executed. This code runs inside the car, so it becomes mandatory to install the .Net framework to implement the managed code.CLR manages the memory through garbage collection and uses some other features like CAS and CTS to execute it efficiently.

Unmanaged code: those applications which are not under the control of CLR are known as unmanaged code. They use pointer variables at the time of execution. This means it is developed by any other language independent of the .Net framework. It uses its runtime environment for compiling and execution. In this, the developers manage the type of safety, memory allocation, security, etc. Several problems related to memory occur, like buffer overflow, memory leak, pointer override, etc., that arise due to this reason.

Q5. What is CAS?

Answer: Code access security is Microsoft’s solution to prevent untrusted codes from performing privileged actions. By this mechanism, common language runtime (CLR) restricts the managed code to execute operations with a limited set of permissions. It uses evidence to help get the right permissions to the right Assembly. It provides evidence-based security built on a layer above the protection provided by Windows.

Q6. What is the difference between the Response.Redirect and Server.Transfer?

Answer: Response. Redirect transfers the request to a new URL and specifies the unique URL. It redirects the user’s browser to another page or site. It forces the client to navigate to the pages they are Redirected to. In HTTP terms, it sends a 302 response to the client.

Server. Transfer transfers the receiver from one page to another, terminates the current page’s execution, and initiates a new page’s performance by using the specified URL of that page. It reduces the server requests by keeping the URLs the same. In this, the browser knows nothing about the process.

Q7. What do you mean by Assembly? Explain different types of assemblies.

Answer: an assembly is a collection of Logic units. This logic unit contains different types and resources to work together to build an application and deploy them using the. Net framework. The CLR uses this information and works over it.

.Net framework supports three kinds of assemblies:

  • Private: the assemblies that are designed to be used by one application and should be located in that application’s directory or subdirectory
  • Shared: the assemblies that require distribution. With shared Assembly, several applications can use the same Assembly and have a dependency on it. Shared assemblies reduce the need for disk and memory space.
  • Satellite: Satellite assemblies are used for deploying language and culture-specific resources for an application.

Q8. What is a garbage collector?

Answer: It manages the allocation and release of memory for your application. This helps in automatic memory management. The unused code objects in the memory get freed by this process.

The memory heap in the Garbage collector is divided into three generations.

  • Generation 0: short-lived objects are stored in this. The process of garbage collection frequently takes place in this generation.
  • Generation 1: medium lived objects are placed here. Those objects which get moved from generation 0 are stored here.
  • Generation 2: This is for long-lived objects.

Garbage collection of generation 2 means it has collected the whole garbage of all the generations, i.e., generation 2 and generation 0 and generation 1.

In this process, the first phase works in the identification of live objects.

In the second phase, the objects which will be compacted get their references updated.

In the third and last phase, the reclamation of space occupied by dead objects is done.

Q9. List the difference between function and stored procedure.

Answer: Function

  • Should return a single value.
  • Cannot work on exception handling using try-catch block.
  • The stored procedure cannot be called using a function
  • Should only have input parameters.

stored procedure

  • This is always used to perform a particular task.
  • Can return zero, one, or more value.
  • It can have both output and input parameters.
  • Exception handling is possible using the try-catch method.
  • The function can be called using a stored procedure.

Q10. What is caching?

Answer: caching means to store data temporarily in the memory so that instead of searching for the data in its original location, one can easily access it from memory. It increases the speed as well as the efficiency of the application.

There are mainly three types of caching.

  • Page caching
  • Fragment caching
  • Data caching

About the Author

ByteScout Team ByteScout Team of Writers ByteScout has a team of professional writers proficient in different technical topics. We select the best writers to cover interesting and trending topics for our readers. We love developers and we hope our articles help you learn about programming and programmers.