.Net Framework Interview Questions

Question 1:

Explain .Net Architecture.

.Net is a generic software development framework that allows to build and run different types of software on top of it.Net framework provides all the services that different type of application needs to run. For example .Net framework provides the ability to applications to communicate to the database, communicate to networking devices, working with XML files, date times and all core functionalities that an application needs.

.Net framework architecture

Image Source: MSDN

.Net framework consists of 2 major components

  • Common language runtime (CLR)  - Responsible for execution of .net applications
  • Framework class library (FCL) - A very large class library, provides all the services that an application needs to run and very helpful in day to day life.

In rest of the subsequent questions will describe each and every component in detail, depicted in above diagram.

Question 2:

What are the major components of .Net framework?

.Net framework is a generic software development framework, on top of which we can develop different types of applications such as

  • Console Application
  • Windows desktop Application
  • Web services
  • XML Web Services
  • Windows phone application
  • Windows Services

.Net framework comes with the following components

  • Common Language Runtime (CLR)
  • Common Type System (CTS)
  • Common Language Specification (CLS)
  • Base class library (BCL)
  • Framework Class Library (FCL)
  • Cross-language interoperability
  • Profiling

Dot Net component stack

Image Source: Wikipedia

Each component is explained in subsequent questions.

Question 3:

What is CLR?

CLR stands for common language runtime. CLR provides the execution environment for .Net applications. CLR is virtual machine similar to JVM (java virtual machine) in Java, which virtualizes execution environment. CLR is available with the almost every version of windows (Windows XP, Windows 7, Windows 8, Windows phone, windows server e.t.c.) by default.

CLR responsibilities

  • Memory Management - Track the objects, allocate memory and clear memory when execution completes so that other parts of application have sufficient memory when need.
  • Operating system independent
  • Hardware independent
  • Language independence
  • Type safety
  • Thread management
  • Exception handling
Question 4:

What is FCL?

FCL stands for Framework class library. Framework class library contains thousands of classes used to build applications and provides all the basic functionalities and services that application needs such as Communication to the database, communication to services, text parsing, working with files e.t.c.

Framework class library


Question 5:

What is BCL/ CL in .Net?

BCL stands for Base class library also known as Class library (CL). BCL is a subset of Framework class library (FCL). Class library is the collection of reusable types that are closely integrated with CLR. Base Class library provides classes and types that are helpful in performing day to day operation e.g. dealing with string and primitive types, database connection, IO operations.

Base class library

Namespace included in Base Class library are as following

System Provides primitive data types, console, array etc.
System.Collections Provide classes to work with collection e.g. List, stack, queue, dictionary
System.Configuration Used for reading and writing program configuration data
System.Data Provide classes to work with Data, ADO.Net
System.Diagnostics Provides tracing, logging, performance counters, etc. functionality
System.Drawing Provide classes to work with graphics
System.Globalization Provide classes to support globalization
System.IO Provides classes to work file files, IO stream.
System.Linq Interface to LINQ providers and the execution of LINQ queries
System.Net Provide classes to work with network protocol e.g. SMTP, TCP
System.Reflection provide classes to read class/assembly information at runtime
System.Resources Provide classes to work with multilingual resources.
System.Security provide classes to work with encryption, hashing etc.
System.Text Provide classes for text encoding, dealing with regular expression
System.Threading Contains methods to manage the creation, synchronization and pooling of program threads
System.Web Classes to work with web application like ASP.Net, Web services and MVC
System.Xml Provide classes to work with XML type

Question 6:

What is MSIL?

MSIL stands for Microsoft Intermediate language, also known as Intermediate language (IL). When we compile source code written in any .Net language e.g. C#, VB, VC++, F# then compiler generates an intermediate code known as MSIL. Further CLR reads MSIL and translates it to native instructions that a computer hardware understands.

MSIL defines instructions for CLR.

Question 7:

What is Manifest?

Assembly manifest file stores assembly metadata information such as how the elements inside the assembly are related to each other. Assembly manifest file includes following information. An assembly manifest information can be stored in standalone in the PE file.

  • Name
  • Version information
  • Culture information
  • Strong name information
  • List of all the files in the assembly - A hash of each file contained in the assembly and a file name
  • Information of referred assemblies - A list of other assemblies that are statically referenced by the assembly.
  • Security identity
Question 8:

How to enforce garbage collection in .NET?

.Net framework provides Collect() method to enforce garbage collector to run. Below is the Syntax.


Question 9:

What is garbage collection?

Garbage collection manages allocation and release of memory for the application. When any application starts, it initializes objects. Common language runtime allocates memory from managed heap when a new object in being initialized. CLR keep initializing memory for all the applications. As the computer memory is limited so its garbage collectors job to free up some memory. Garbage collector's optimizing engine determines which is the best time to clean memory. Garbage collector frees up memory by removing the object that are not in use.

Question 10:

What is difference between dispose () and finalize () method in .net?

Dispose () and finalize () methods are used to release memory held by unmanaged resources database connections, file IO operations, COM objects. The main difference in between two is that finalize () method is called by garbage collector (GC) internally to free up memory while dispose () method is called by user code explicitly.

To call dispose () method explicitly, class need to implement IDisposible interface.

It is best practice to implement dispose () method to free up memory as it will immediately free up memory as soon as the currently executing code block completes. Garbage collector does not call finalize () method immediately, so it has some performance impact.

Share interview questions


comments powered by Disqus


Social Media