Home » .Net framework interview questions and answers

.Net framework interview questions and answers

What is the .Net framework?

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.

What is an IL Code?

IL is a partially compiled code. Half compiled code means the code is not compiled to the machine.

Who compiles the IL code?

IL code is compiled by JIT(Just In Time) compiler

What are the different types of JIT Compiler?

In .NET there are three types of JIT

  1. Normal JIT : Compiles only those methods that are called at runtime and These methods are compiled for first time when they called , then they are stored in Cache. When same method called for second time , then compiled code is load from the cache memory and used for execution
  2. Econo JIT : Compiles only those methods that are called at runtime. These compiled methods are not stored in cache memory so RAM(Random Access Memory) is utilized. Econo JIT takes less memory becuase it is not stored compiled code in cache.
  3. Pre JIT: Compiles the code into native code in single compilation cycle. This is done at the time of deployment of application. It is achieve by using ngen.exe

What is CLR in .NET?

CLR stands for Common Language Runtime. CLR consider as heart of the .NET framework. It does four main task

  1. Garbage Collection
  2. CAS(Code Acces Security)
  3. CV(Code Verification)
  4. IL to Native conversion

What is the difference between managed and unmanaged code?

Code executes by CLR environment is called managed code. Unmanaged code runs outside the CLR environment. An example of Unmanaged code is code written in c++. Unmanaged code has its own environment.

What is Garbage Collector?

The garbage collector is a feature of CLR. It clears the Managed Unused object and frees the memory. The garbage collector is background thread run after some time interval and check if there any unused managed objected are present.

Note: Garbage Collector is not clean the Unmanaged Objects, it can only claim the managed object memory.

What are generations in GC(Garbage Collector)

There are three generations of GC

  1. Gen 0 : When application create fresh objects , they are marked it as Gen 0
  2. Gen 1: When GC is not able to clean objects from the gen 0 then its move to gen 1
  3. Gen 2: When GC not clear objects from Gen 1 then its move to gen 2

Generations are created to improve the performance of the GC, GC spends more time in Gen 0 as compared to Gen 1 and 2. The more objects are in Gen 0, more application is stable

What is CTS(Common Types System)?

In .NET there are multiple languages like c#, VB.NET, F#, etc There can be situations when we want to code in one language to be called in another language. To smooth communication between these languages, the most important thing is that they should have a CTS. CTS ensures that data types in two languages get compiled to a common data type.

What is a CLS(Common Langauge Specification)?

CLS in the subset of CTS. CLS is a specification or guidelines or Set of rules. It defined the necessary standard for programming language

example: In c# any line ends with a semicolon, this has been specified in CLS, If we don’t put a semicolon it will throw a compile-time error.

What is an Assembly?

Assembly is a unit of deployments like EXE or a DLL

What is the meaning of CAS in the .NET framework?

CAS stands for Code Access Security. It prevents unauthorized access to programs and resources in the runtime.

What is the use of GAC in .NET?

GAC is the abbreviation of Global Assembly Cache. It stores the assemblies that are shared across all of the applications. gacutil is used to add any file into the GAC easily.