Search This Blog

Friday 5 September 2014

Interview Questions for 5+ years Experience in dotnet

Interview Questions for 5+ years Experience in dotnet

1.Tell about your last project you worked on?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
Indexers are used for treating an object as an array. 
For more info refer:
http://www.dotnetspider.com/forum/160680-indexes-.NET.aspx 

9.What is the difference between abstract classes and interfaces?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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:
http://www.dotnetspider.com/resources/42949-sorting-user-defined-collection-c-using.aspx

14.What is the difference between ref and out keyword. Is out a Reference variable?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
Yes

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

23.Difference between Internal and Protected access modifiers.
Answer:
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.
Answer:
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?
Answer:
Decorate the method with the WebMethod attribute as shown below:
[System.Web.Services.WebMethod()]
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?

No comments:

Post a Comment