5+ years .Net Interview Questions

In this article I am listing the Questions along with the Answers that were asked in my .Net Interview Today with Tata Consultancy Services. I have over 5+ years experience in .Net,Web Services and WCF Services.

Interview Questions for 5+ years Experience in dotnet

1.Tell about your last project you worked on?
Tell about the recent project you have worked on. The technology and the database you have worked on. Your roles and responsibilities.

2.When was the last time you did coding?

3.What is an assembly?
PreCompiled code that can be executed by the .NET runtime environment. It can be an .exe or .dll

4.What are different kind of assemblies? What is satellite assembly and public assembly?
There are three types of assemblies:
a.Public Assembly:dll which can be used by multiple applications at a time. It is generally stored in GAC(Global Assembly Cache).
b.Private Assembly:It is used by only one application and generally stored in the Application specific folder.
c.Satellite Assembly:A Satellite Assembly contains only static objects such as images and other non-executable files such as resource-only files that are required by the application.

5.Can we have 2 assemblies with the same name in GAC?
Yes we can have 2 assemblies with the same name in GAC as long as they have different strong names. The strong names of the assemblies can differ in name/version/culture/processor architecture/public key token.

6.What is the prerequisite to deploy an assembly in GAC?
The assembly must be strong named. A 'strongly named' assembly is an assembly that is signed with a key to ensure its uniqueness

7.What is Strong Name?
A strong name is a combination of its name, version number, and culture information (if provided) and a public key and a digital signature. This ensures that the Dll is unique.
•Strong names provides an integrity check that ensures that the contents of the assembly have not been changed since it was built.

8.What are indexers?
Indexers are used for treating an object as an array.
For more info refer:

9.What is the difference between abstract classes and interfaces?
Interface must have only methods without implementation whereas abstract classes can have methods with and without implementation that is you can define a behavior in an abstract class. An interface cannot contain access modifiers whereas an abstract class can contain access modifiers. A class can implement multiple interfaces whereas a class can inherit only one abstract class. An interface cannot have variables whereas an abstract class can have variables and constants defined. When we add a new method to an interface, We have to track all the classes which implement this interface and add the functionality to this method whereas in case of abstract class we can add default behavior for the newly added method and thus the class which inherit this class works properly.

10.Have you worked on Threading?
I did not get a chance to work on threading but I have knowledge about the threading concepts.

11.What are generics? how do you increase performance using generics?
Generics allows you to define type-safe data structures, without specifying the actual data types. This increases the performance of the code and code resuse. Thus generics allows you to write a class or method that can work with any data type. Since Generics is type safe it avoids boxing and unboxing which increases the performance of the code because you need not convert an object to a specific datatype and viceversa.

12.How do you compare two dictionary objects?
You can use the SequenceEqual method of the dictionary object to compare 2 dictionaries as shown below:
bool result = dic1.SequenceEqual(dic2);
Here result will be true if the two dictionary objects are equal else false.

13.Have you heard about IComparable? How does it work?
A Class can implement IComparable interface if you want to compare the objects of that class. then in that class we have to implement the CompareTo method and provide the implementation to compare two class objects.
For more info refer:

14.What is the difference between ref and out keyword. Is out a Reference variable?
ref is initialized before entering the function which is called, whereas out variable is initialized inside the function. The out keyword used for a variable causes it to be passed by reference. It is used when a method has to return multiple values(one using return statement other using out keyword).

15.What is Managed code?
Managed code is the code whose execution is managed by the .NET Framework Common Language Runtime(CLR). The CLR ensures managed execution environment that ensures type safety, exception handling,garbage collection and array bound & index checking.

16.What is UnManaged Code?
Applications that do not run under the control of the CLR are said to be unmanaged. this is the code that is directly executed by the operating system.

17.How Unmanaged code is taken care by .Net Framework?
In unmanaged code the memory allocation, type safety, security and other things have to be taken care by the developer. This can lead to memory leaks and buffer overrun.

18.What is Dispose and Finalize?
The Dispose method is generally called by the code that created your class so that we can clean up and release any resources we have acquired ( database connections/file handles) once the code is done with the object. The finalize method is called when the object is garbage collected and its not guaranteed when this will happen.

19.ASP.NET Page Lifecyle events?
Page_PreInit,Page_Init,LoadViewState(If it is a Postback),LoadPostBackData(If it is a Postback),Page_Load,Control event handler execution,Page_PreRender,SaveViewState,Page_Render,Page_Unload

20.In an ASP.NET page if you have a DropdownList and whenever you select some option in the dropdown list? It makes a post back to server. How can you increase the performance of this page?
put the dropdownlist inside an AJAX UpdatePanel so it updates only that part of the page instead of a full page reload or we can also use AJAX webservice.

21.Have you used Caching in asp.net?

22.What are difference Session Management Techniques in ASP.NET
Sessions,Cookies,QueryString,ViewState,Application objects,Hidden Fields.

23.Difference between Internal and Protected access modifiers.
A protected type or member can be accessed by code in the same class or in a derived class wheareas An internal type or member can be accessed by code in the same assembly.

24.Difference between ReadOnly and Const.
A Const can be initialized only once whereas ReadOnly can be initialized at runtime in the constructor.
•Constants are static by default that is they are compile time constants
whereas Readonly are runtime constants.
•Constants must have a value at compilation-time and they are copied into every assembly that uses them.
Readonly instance fields must be set before the constructor exits because they are evaluated when object is created.

Web Services Questions:
since I had experience in Web Service. They asked below questions in webservice?

1.How do you mark a service method as webservice method?
Decorate the method with the WebMethod attribute as shown below:
public string GetData(string message)
return "My Service";

2.In a Web service If you have multiple methods and you have to make only one method as Web service method How can you do it?

Article by Vaishali Jain
Miss. Jain Microsoft Certified Technology Specialist in .Net(Windows and Web Based application development)

Follow Vaishali Jain or read 127 articles authored by Vaishali Jain


Author: Phagu Mahato29 Nov 2013 Member Level: Gold   Points : 7

Thank for posting your valuable code snippet . Now I posted some or answer of your question
[16 . Answer] unmanaged code provides of outside the security perimeter for managed code, due caution is required. For example native code APIs . UnmanagedCode executed by the OS directly.

[9. Answer] . There are several difference Between Interface and Abstract Class some of example as below.
[1]interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
Variables declared in a Java interface is by default final.
[2] An interface is similar to an abstract class; indeed interfaces occupy the same namespace as classes and abstract classe

interface MotorVehicle
void run();

int getFuel();

class Moter implements MotorVehicle

int fuel;

void run()

int getFuel()
return this.fuel;

An abstract class is a class that can not be instantiated but that can contain code.while An interface only contains method definitions but does not contain any code

Author: Ritesh21 Feb 2014 Member Level: Bronze   Points : 5

3. What is an assembly?


An assembly is a collection of types and resources that forms a logical unit of functionality.

When you compile an application, the MSIL code created is stored in an assembly .
Assemblies include both executable application files that you can run directly from Windows without the need for any other programs (these have a .exe file extension), and libraries (which have a .dll extension) for use by other applications.

There are two kind of assemblies in .NET;
I> Private
II> Shared

Private assemblies are simple and copied with each calling assemblies in the calling assemblies folder.

Shared assemblies (also called strong named assemblies) are copied to a single location (usually the Global assembly cache). For all calling assemblies within the same application, the same copy of the shared assembly is used from its original location. Hence, shared assemblies are not copied in the private folders of each calling assembly. Each shared assembly has a four part name including its face name, version, public key token and culture information. The public key token and version information makes it almost impossible for two different assemblies with the same name or for two similar assemblies with different version to mix with each other.

Author: Ritesh21 Feb 2014 Member Level: Bronze   Points : 1

21. Cashing in dot net.

Caching is a technique of storing data in memory which takes time to create. Caching is one of the best features of the ASP.NET. For example, you could cache the data from complex query which takes time to fetch data. The subsequent requests would not need to fetch data from the database. You can get data directly from the cache. By using the cache, you can improve the performance of your application.

There are two main types of caching:

1. Output caching
2. Data caching

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: