.NET Interview Questions and Answers

Hello Programmer,

I know you have been searching for some good .net interview questions and their answers all over the internet. You have reached your destination from where you can learn the same. Here I have given the answers in a simple way so that you can get it in your first read. So go ahead and impress the interviewers.

Best of Luck. :-)

Part 1 : Basic .Net Framework

1. What is an IL/ MSIL / CIL/ JIT?

  :- Intermediate Language (IL) is also known as Microsoft IL (MSIL) or Common IL (CIL).
     All .Net source code is compiled to IL. This IL is then converted to machine code by
    Just-In-Time (JIT) compiler.

2. What is CLR?

 :- Common Language Runtime (CLR) forms the heart of .Net framework. Its responsibility
    is to take care of the code execution of the program. For eg: Java has JVM (Java
    Virtual Machine) just like .Net has CLR.


    a) Garbage Collection : It is done by Garbage Collector (GC). GC automatically manages
                                      memory and thus eliminates memory leak. When objects are not
                                      referred, GC releases those memories thus providing efficient
                                      memory management.

    b) Code Access Security (CAS) : It grants rights to program depending on the security
                                      configuration of the machine. For eg: Program has rights to 
                                      edit or create a new file but the security configuration of the 
                                      machine does not allow the program to delete a file.
                                      Also CAS will take care that the code runs under the
                                      environment of machine's security configuration.

    c) Code Verification :  This ensures the proper code execution and type safety
                                     while the code runs. It prevents the source code to perform
                                     illegal operations such as accessing invalid memory locations etc.

    d) Intermediate Language : CLR uses JIT compiler and compiles the IL to machine code
                                     and then executes. 

3. What is CTS?

   :- Inorder to make 2 languages communicate smoothly, CLR uses CTS or Common
      Type System.
      For eg: 'Integer' in VB6 and 'int' in C++ are not compatible but by using CTS, both of
      them are converted to 'System.Int32' which is a datatype of CTS and is compatible.

4. What is CLS?

  :- Common Language Specification (CLS) is a subset of CTS which all .Net languages
     are expected to support. This is the guidelines that all languages should follow
     so that it can communicate with other .Net languages.

5. What is Managed Code?

  :- Managed Code (MC) runs inside the environment of CLR (i.e .Net runtime). In short all
     IL are MC.
     If we are using a third party software, for eg: VB6 / VC++ component, they are 
     unmanaged code as .Net runtime (CLR) does not have control over the source code 
     execution of the language.

6. What is an Assembly?

  :- Assembly is a unit of deployment like DLL or EXE. 
     Assembly consists of one or more files i.e dll's, exe's, html files etc and represents a
     group of resources, type definitions and implementations of those types.
     An assembly may also contain references to other assemblies. These resources, types
     and references are described in a block of data called Manifest. 
     Manifest makes an assembly self describing. CLR uses this data for everything.

7. Which are the types of Assembly?

 :-  There are 2 types of Assembly;
      a) Private : It is normally used by a single application and is stored in Application's
                       directory or sub-directory.
      b) Public/Shared : It is usually libraries of code which many applications find useful. 
                       eg: Crystal Reports which will be used by many applications for reports.
                       Public assembly is normally stored in Global Assembly Cache (GAC), which
                       is a repository of assemblies maintained by .Net Framework.

8. What is Manifest?

  :- Assembly metadata is stored in Manifest. It contains all the metadata needed to do the
     following things;
          1. Version of Assembly 
          2. Security Identity
          3. Scope of the Assembly

9. What is GAC?

  :- Global Assembly Cache (GAC) is used where shared .Net assembly reside.i.e 
       - it is used when the application has to be shared among several applications.
       - If the Assembly has some special security requirements like only administrators can
         remove the assembly.

10. What is the concept of Strong Names?

  :- Strong Names are needed only when we need to deploy assembly in GAC. It helps GAC
     to differentiate between versions. Strong Names use Public Key Cryptography (PKC)
     to ensure that no one can spoof it. (PKC uses Private key and Public key concept).

11. What is Garbage Collection?

  :- Garbage collection is a CLR feature which automatically manages memory. It
     automatically releases objects when they are no longer in use and referenced. 

12. Code to force GC to run?

  :- System.GC.Collect();

13. What is Reflection?
  :- All .NET assemblies have metadata information stored about the type defined in
     modules. This metadata information can be accessed by mechanism called Reflection

To be continued...

No comments:

Post a Comment


About Me

I am Tijo Tom, a Computer Engineer from India.Right from my schooling, I had a passion for Programming, PC Tricks, Virus Creation and Hacking.

I started this blog on Jan 1, 2014 to share my views and ideas with the world.

You can know more about me on