Dot Net Interview Questions – Set-02

What is an EXE and a DLL?

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 which share this DLL need not worry about the code intricacies as long as it is able to call the function on this DLL.

What is meant by Managed and Unmanaged code?

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 .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.

What are the different validators in ASP.NET?

  • Client-side validation – When the validation takes place on the client-side browser, it is called client-side validation. Usually, JavaScript is used for client-side validation.
  • Server-side validation – When the validation takes place on the server then it is called server-side validation. Server-side validation is considered as a secure form of validation because even if the user bypasses the client-side validation we can still catch it in server-side validation.

What is Caching?

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

How is a Managed code executed?

Follow these steps 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.

What do the following acronyms in .NET stand for: IL, CIL, MSIL, CLI and JIT?

IL, or Intermediate Language, is a CPU independent partially compiled code. IL code will be compiled to native machine code using current environmental properties by Just-In-Time compiler (JIT). JIT compiler translates the IL code to an assembly code and uses the CPU architecture of the target machine to execute a .NET application. In .NET, IL is called Common Intermediate Language (CIL), and in the early .NET days it was called Microsoft Intermediate Language (MSIL).

CLI, or Common Language Infrastructure, is an open specification developed by Microsoft. It is a compiled code library used for deployment, versioning, and security. In .NET there are two CLI types: process assemblies (EXE) and library assemblies (DLL). CLI assemblies contain code in CIL, and as mentioned, during compilation of CLI programming languages, the source code is translated into CIL code rather than into platform or processor specific object code.

To summarize:

  • When compiled, source code is first translated to IL (in .NET, that is CIL, and previously called MSIL).
  • CIL is then assembled into a bytecode and a CLI assembly is created.
  • Before code execution, CLI code is passed through the runtime’s JIT compiler to generate native machine code.
  • The computer’s processor executes the native machine code.

What languages does the .NET Framework support?

Answering this question shows you have the basic knowledge and skills required to fulfill the needs of the position. The right candidate should be a knowledgeable programmer who is comfortable coding within the .NET Framework. In addition to telling what languages the framework supports, you can also provide your experience programming within those languages.

Example: “The .NET Framework supports more than 60 languages. This includes both Microsoft and non-Microsoft languages. The most common languages are VB.NET, Cobol, Perl, C#, C++ and F# languages.

I began my programming career by learning C#. It’s provided an important foundation for my professional development as a programmer. When I got my C# programming certificate, I was promoted to a full-time developer at National Telecom Ltd. In that role, I also learned F# and Cobol. This makes me very familiar with these common languages applied to the .NET Framework.”

What are differences between system.stringbuilder and system.string?

The main differences between system.stringbuilder and system.string are:

  • system.stringbuilder is a mutable while system.string is immutable.
  • Append keyword is used in system.stringbuilder but not in system.string.

How can a class be prevented from being inherited?

To prevent a class from being inherited, the sealed keyword in C# can be used. The NotInheritable keyword can be used in VB.NET to prevent accidental inheritance of the class.

Explain the difference between managed and unmanaged code.

Managed code is a code created by the .NET compiler. It does not depend on the architecture of the target machine because it is executed by the CLR (Common Language Runtime), and not by the operating system itself. CLR and managed code offers developers few benefits, like garbage collection, type checking and exceptions handling.

On the other hand, unmanaged code is directly compiled to native machine code and depends on the architecture of the target machine. It is executed directly by the operating system. In the unmanaged code, the developer has to make sure he is dealing with memory usage and allocation (especially because of memory leaks), type safety and exceptions manually.

In .NET, Visual Basic and C# compiler creates managed code. To get unmanaged code, the application has to be written in C or C++.