a blog for those who code

Sunday 31 August 2014

Asp Net Interview Questions and Answers - Part 1

In this post you will find Interview Questions for Mid-Level Developer in Dot Net. These questions will be helpful for those who are preparing for Interview.

1. What is the Difference between Interface-oriented, Object-oriented and Aspect-oriented programming ?

Interface Oriented Programming exists outside the world of COM (Component Object Model). It is a programming discipline that is based on the separation of the public interface from implementation. It is a contract based approach, that means neither side of the interface cares how the other does its work. For example, WSDL based web services are the example of this type of programming.

Object Oriented Programming is a programming language model organized around objects rather than actions and data rather than logic. OOP integrates code and data using concept of an Object. The characteristics of Object Oriented Systems are Abstraction, Encapsulation, Inheritance and Polymorphism.

Aspect Oriented Programming looks at how many components or pieces of a system might need to interact. It mainly separates cross-cutting concerns into single units called aspects. An aspects is a sub program which is associated with the specific property of a program.

2. What is an Interface and how it is different from a Class ?

Interface is a contract that defines the signature of the functionality. It looks like a class but has no implementation. When we create an Interface, we are creating a set of methods without any implementation that must be overridden by the implemented class.

Interface contains only signature of methods, delegates or events whereas class can have method implementation. We can declare variable in Classes whereas in Interface we cannot. Classes are inherited by another class but Interfaces are implemented. Interface is used to support multiple inheritance as because we can implement more than one interface in a class but we cannot inherit more than one class in a class.

3. What is the difference between Finalize() and Dispose() ?

Finalize() is called by Garbage Collector when an object's memory is no longer referenced by an active code whereas is you want to explicitly release some specific objects then its best to implement IDisplosable and override the Dispose() method of IDisposable interface. Finalize is non-deterministic, since it's called by garbage collector. Dispose is a function and needs to be called by the developer for clean up.

4. What is the difference between in-proc and out-of-proc ?

An in-proc server runs on the same process area as that of the client. The advantage of in-proc is its speed but the disadvantage of using this is that if any of them crashes it takes the other one down with it. Out-of-proc is one which works outside the client's memory thus giving it a stability, but it is little slower than the in-proc.

5. What is the difference between early-binding and late-binding?

Early Binding refers to compile time binding whereas Late Binding refers to run time binding. Early binding gives you faster access at runtime to an object's methods and properties whereas Late Binding gives you slower access at runtime because code has to search for the object's methods and properties at runtime. To use early binding you have to instantiate the object with the New keyword whereas to use late binding you have to instantiate your object with CreateObject.

6. What is GAC ? What problem does it solve ?

GAC (Global Assembly Cache) is where all shared .Net assembly resides. Every computer which has CLR installed has a machine wide code cache called GAC. The GAC stores assemblies that are to be shared by several applications on the computer.

GAC solves the problem of DLL Hell and DLL versioning. When a .Net component is installed in a system,  GAC looks at its version and creates a strong name for the component. The component then registered in the repository and indexed by its strong name rather than the version number. So there will be no confusion if more than one version of a component is present in a system.

7. What is the difference between Debug.Write and Trace.Write ?

In C#, you have been provided with two classes Debug and Trace. In debug mode both are enabled whereas in release mode Debug functions are disabled while the Trace functions remain enabled. Thus if you want to write while building in a debug mode you can use any of the two Debug.Write or Trace.Write methods. In release mode you cannot use Debug.Write, so you need to use Trace.Write.

8. How is 'Server.Transfer' different from 'response.Redirect' ?

'Response.Redirect' sends a message to the browser, telling it to move to another page. 'Server.Transfer' instead of telling to browser to redirect, redirects the user directly from the server itself. So, we can say that in 'Server.Transfer' there is no round trip whereas 'Response.Redirect' has a round trip and hence puts load on the server. You cannot use 'Server.Transfer' to send the user to external site, whereas using 'Response.Redirect' you can do that.

9. What are the types of Authentication in Asp.Net ?

There are three types of authentication in Asp.Net
Windows Authentication -  This authentication method uses built-in windows security features to authenticate users.
Forms Authentication - This authentication method used a customized list of users or users from the database who are authenticated using a login screen.
Passport Authentication - This authentication method uses Microsoft Passport services, sites like MSN, to authenticate the users.

10. What are Session state modes in Asp.Net ?

There are three types of session state modes in Asp.Net
Inproc - In this mode the session state is stored locally on the memory of the same web server where the application is running. In this mode state is stored in the memory space of the Aspnet_wp.exe process.
StateServer - In this mode the session state is serialized and stored in a separate process. The advantage of using this type of session state is that session state will remain preserved when web application will be restarted.
SQL Server - In this mode the session state is serialized and stored in a SQL Server database. It has the same advantage as that of StateServer.

Please Like and Share the Blog, if you find it interesting and helpful.

No comments:

Post a Comment