Monday, February 28, 2011

C# Interview questions:- What role did your play in your current project?

C# Interview questions:- What role did your play in your current project?



Answer:
This is again a great c# interview question , but .NET professionals tend to answer this
question in one liners like i am a developer , project manager.

In todays world people expect professionals who can do multitasking. The best way to approach the answer is by explaining what things did you do in the complete SDLC cycle. Below goes my version of the answer , you can tailor the same as per your needs.
My main role in the project was coding , unit testing and bug fixing. Said and done that i was involved in all phases of the project.

I worked with the business analyst in the requirement phase to gather requirements and was a active member in writing use cases.

I also assisted the technical architect in design phase. In design phase i helped the architect in proof of concept and putting down the technical design document.

My main role was in coding phase where i executed project with proper unit testing.

In system integration test and UAT i was actively involved in bug fixing.
Other than the project i help COE team for any kind of RND and POC work.
In case you are doing some extra activities in the company like helping COE , presales team or any other initiative do speak about the same.

Watch my 50 C# interview questions and answers

ASP.NET Interview question :- What are HttpHandler and HttpModules and how do they differ?

ASP.NET Interview question :- What are HttpHandler and HttpModules and how
do they differ?


Answer:

Both the above concepts are rarely used by developers but mostly asked
in .NET interviews .

The prime and common goal of HttpHandler and httpModule is to inject pre-processing logic before the ASP.NET request reaches the IIS server.

HttpHandler is a extension based processor in other words pre-processing logic is executed depending on file extensions. For instance sometimes you would like to check that a person should be above age of 18 if he is trying to view any files with extension *.MP4.

HttpModule is event based processor. ASP.NET engine emits out lot of events as the request traverses over the request pipeline. Just to name some events beginrequest ,authorizerequest,authenticaterequest etc. By using HttpModule you can write logic in these events. These logic get executed as the events fire and before the request reaches IIS server.

So a short answer for the above.NET interview question would be HttpHandler is a extension based processor while HttpModule is a event base processor. Both of them help to inject pre-processing logic before the ASP.NET request reaches the IIS server.
See my Top ASP.NET Interview questions and answers

Saturday, February 26, 2011

ASP.NET interview question :- How do we write a HttpModule ?

ASP.NET interview question :- How do we write a HttpModule ?



Answer:

Again a simple .NET Interview question Writing a HttpModule is a two step process.
Create a class which implements IhttpModule.

  public class clsHttpModule : IHttpModule
 {

 public void Init(HttpApplication context)
 {
    this.httpApp = context;
    httpApp.Context.Response.Clear();
    httpApp.AuthenticateRequest += new EventHandler(OnAuthentication);
    httpApp.AuthorizeRequest += new EventHandler(OnAuthorization);
 ....
 ....
 ....

 }
 void OnAuthorization(object sender, EventArgs a)
 {
     //Implementation
 }
 void OnAuthentication(object sender, EventArgs a)
 {   
     //Implementation
 }
 }

Make a entry in the web.config file.

  <httpModules>
<add name="clsHttpModule" type="clsHttpModule"/>
</httpModules>

Do view my top .NET interview questions and answers

ASP.NET Interview question :- How do we write a HttpHandler ?

ASP.NET Interview question :- How do we write a HttpHandler ?


Answer:
This is a simple a .NET Interview question .Its a two step process.

First create a class which implements Ihttphandler
public class clsHttpHandler : IHttpHandler
{
   public bool IsReusable
   {
       get { return true; }
   }
   public void ProcessRequest(HttpContext context)
   {
      // Put implementation here.
   }
}

Step 2 make a entry in the web.config file.

<httpHandlers>
<add verb="*" path="*.gif" type="clsHttpHandler"/>
</httpHandlers>

You can view my top ASP.NET Interview questions and answers

Friday, February 25, 2011

ASP.NET interview question:-What is the difference between render and prender event ?

ASP.NET interview question:-What is the difference between render and prender event ?


Answer:
This is again a very nice .NET interview question and the question can be confusing because of the common word "render". Now ASP.NET page has 4 important events. Init , Load , validate ,
event and render (Remember SILVER).

Now the final render is a actually a two step process.
1- First the ASP.NET UI objects are saved in to view state.
2- loaded viewstate is assembled to create the final HTML.
The first step is pre-render event and the second step is the render event.

Prerender
This is the event in which the objects will be saved to viewstate.This makes the PreRender event the right place for changing properties of controls or changing Control structure.Once the PreRender phase is done those changes to objects are locked in and the viewstate can not be changed. The PreRender step can be overridden using OnPreRender event.

Render.
Render event assembles the HTML so that it can be sent to the browser.In Render event developers can write custom HTML and override any HTML which is created till now.The Render method takes an HtmlTextWriter object as a parameter and uses that to output HTML to be streamed to the browser. Changes can still be made at this point, but they are reflected to the client only i.e. the end browser.

View my top .NET Interview question and answers

.NET interview question on generics :- How does performance increase by using generic collection ?

.NET interview question on generics :- How does performance increase by using generic collection ?


Answer:
When we use normally .NET collection objects there is lot of boxing and unboxing. When we create a collection which is a generic collection its strongly typed. As its strongly typed boxing and unboxing gets eliminated and thus increasing performance.
See my 32 important C# interview questions

Wednesday, February 23, 2011

.NET Interview Questions:-What is the sequence in which ASP.NET page life cycle is executed ?

.NET Interview Questions:-What is
the sequence in which ASP.NET page life cycle is executed ?



Answer:
This is a great and the most asked ASP.NET interview question. Out of 100 .NET interviews atleast 70 interviewer will ask this question. The answer is very simple but the problem with the answer is that developers forget the sequence of ASP.NET page life cycle.

The best way to remember this answer is by remembering the word SILVER.
S (Well this word is just to make up the word , you can just skip this.)
I (Init)
L (Load)
V (Validate)
E (Event)
R (Render)

Please see my 22 top .NET Interview questions and answers

Tuesday, February 22, 2011

C# interview question :- Why is stringbuilder concatenation more efficient than simple string concatenation?

C# interview question :- Why is stringbuilder concatenation more efficient than simple string concatenation?


Answer:

This question is one of the favorites question which comes during c# interviews and the interviewer is not only expecting which one of them is more efficient. But he is also expecting the reason for the same.

In order to understand the same better lets consider the below scenario where we have two lines of code which does string concantenation.
For a simple string concatenation code shown below it will create 3 copies of string in memory.

//The below line of code Creates one copy of the string
string str = "shiv";

/* The below line of  code creates three copies of string object one for
the concatenation  at right hand side and the other for new value at the
left hand side. The first old allocated memory is sent for garbage
collection.*/
str = str + "shiv";

When you use the string builder for concatenation it will create only one copy of the object.

/* The below code uses string builder and only one
object is created as compared to normal string where we have 3 copies created*/
StringBuilder objBuilder = new StringBuilder();
objBuilder.Append("shiv");

Ok now summarizing what should we say to the interviewer.
String is immutable. Immutable means once assigned it can not be changed. Thats why it creates more copies of the object as it can not use the same instance.String builder is mutable ,in other words the same object will changed rather than creating new objects.
So string builder is more efficient as compared to simple string concatenation.


See my 300 important c# interview questions and answers

.Net Interview Questions:-If you are said to improve .NET code performance what will you do ?

.Net Interview Questions:-If you are said to improve .NET code performance what will you do ?



Answer:

These kind of questions are very generic. Just pick up 5 best tips you know which you implemented and say it before the interviewer. Below goes my 5 best tips-

  • Use stringbuilder as compared to normal string concatenation.

  • Use stored procedure rather than inline sql code.

  • Use caching for frequently used data.

  • Use generics collection as compared to simple collection , to avoid boxing / unboxing.

  • Remove unnecessary boxing and unboxing code.

  • In case you are using unmanaged code use the dispose final function for clean up.

My 50 .NET Interview questions and answers

Monday, February 21, 2011

SQL Server interview question :- Select record with the second lowest value from the below customer table?

SQL Server interview question :- Select record with the second lowest value from the below customer table?


Answer:

Below is a simple customer table with 3 fields code , name and amount. Can you select the customer with second lowest amount. This is one of the favorite questions which is asked to test your SQL Server skills.



Below is the answer. It can be accomplished by using sub queries. First select the min and then get all records which are more than the min and select top 1 from the same. Below goes the query.

select top 1 * from tbl_Customer touter where touter.Amount > (SELECT
min(tinner.Amount)
 FROM [Customer].[dbo].[tbl_Customer] as
tinner)
 order by touter.Amount asc

Some time interviewers can trick you questions like select the second top. In the subquery we just need to change the same to max.

Get 200 SQL Server Interview questions and answers or .NET Interview questions and answers

Saturday, February 19, 2011

.NET Interview Question - How does “Dataset” differ from a “Data Reader”?

.NET Interview Question - How does “Dataset” differ from a “Data Reader”?


• “Dataset” is a disconnected architecture, while “Data Reader” has live connection while reading data. If we want to cache data and pass to a different tier “Dataset” forms the best choice and it has decent XML support.

• When application needs to access data from more than one table “Dataset” forms the best choice.

• If we need to move back while reading records, “data reader” does not support this functionality.

• However, one of the biggest drawbacks of Dataset is speed. As “Dataset” carry considerable overhead because of relations, multiple table’s etc speed is slower than “Data Reader”. Use “Data Reader” when you want to quickly read and display records on a screen.


Click here for more 22 top .NET Interview Questions

.NET Interview Question - How does delegate differ from an event?

.NET Interview Question - How does delegate differ from an event?

Delegate is an abstract strong pointer to a function or method while events are higher level of encapsulation over delegates. Events use delegates internally.

They differ for the below reasons:-

• Actually, events use delegates in bottom. But they add an extra layer on the
delegates, thus forming the publisher and subscriber model.

• As delegates are function to pointers, they can move across any clients. So any of the clients can add or remove events, which can be confusing. But events give the extra protection / encapsulation by adding the layer and making it a publisher and subscriber model.


Click here for more 32 .NET/ASP.NET Interview Questions

Thursday, February 17, 2011

.NET and OOP interview questions :- What is the difference between abstraction and encapsulation ?

.NET and OOP interview questions :- What is the difference between abstraction and encapsulation ?


Answer:
This is a very typical .NET interview question which confuses most of the .NET professionals. Both abstraction and encapsulation look similiar , but they have huge differences between them.
Abstraction is nothing but simplifying objects while encapsulation is hiding complexity.

Encapsulation implements abstraction. Abstraction is a thought process which happens during planning phase. While encapsulation implements abstraction by using access modifiers ( private, public, protected, internal and protected internal).



Get the 500 .NET Interview questions and answers

Tuesday, February 15, 2011

.NET Interview questions for Interfaces:- If A class inherits from multiple interfaces and the interfaces have same method names. How can we provide different implementation?.

.NET Interview questions for Interfaces:- If A class inherits from multiple interfaces and the interfaces have same method names. How can we provide different implementation?.


Answer:
This is again one those typical .NET Interview questions which move around interfaces to confuse the developer.

For providing differentimplementation you can qualify the method names with interface names as as shown below. A reference to I1 will display "This is I1" and reference to I2 will display "This is I2". Below is the code snippet for the same.

interface I1
{
void MyMethod();
}
interface I2
{
void MyMethod();
}
class Sample : I1, I2
{
public void I1.MyMethod()
{
Console.WriteLine("This is I1");
}
public void I2.MyMethod()
{
Console.WriteLine("This is I2");
} 
}

50 .NET Interview questions and answers

Wednesday, February 9, 2011

.NET/ASP.NET Interview Questions:- What is Polymorphism? How does VB.NET/C# achieve polymorphism?


.NET/ASP.NET Interview Questions:- What is Polymorphism? How does VB.NET/C# achieve polymorphism?


This is a nice and simple OOP interview question. As the name says POLY (Many) MORPHISM (Change). Polymorphism is the ability of the object to behave differently under different conditions. For instance a simple user object can behave as a admin user or as a simple user
depending on conditions.
There are two ways of doing polymorphism dynamic and static. Static polymorphism is achieved by using method overloading and dynamic polymorphism is achieved by using method overriding. Please note do confuse with overloading and overriding while answering this question. Many .NET developers make a nice versa statement leading to lot of confusion.

Click here for more 40 fundamentals .NET interview question

ASP.NET Site Performance Secrets

ASP.NET Site Performance Secrets


I have just reviewed a book written by Matt Perdeck ASP.NET site performance secrets.If you are really serious about ASP.NET site performance GRAB this. I am not recommending this book because I have reviewed it.

On my personal experience when I was reviewing/reading this book Matt pointed to so many facts which I as MVP was not aware of the same. My favorite topic in the book was IIS compression. Great work.... keep it up Matt.

Tuesday, February 8, 2011

Asp.Net Interview Questions:-How to implement security in webservice in asp.net

Asp.Net Interview Questions:-How
to implement security in webservice in asp.net


This is one of the most confusing ASP.NET interview question and very less developers are aware of the answer.


Webservice runs in the context of IIS and ASP.NET runtime. So you can apply all the security methodologies which you do for ASP.NET i.e. windows , passport and forms.


Click here for 32 basic .NET interview questions and answers

Monday, February 7, 2011

.Net and ASP.NET Interview Questions- Why can't we instantiate an abstract class?

.Net and ASP.NET Interview Questions- Why can't we instantiate an abstract
class?


Answers:-
This is a nice .NET interview question. Abstract class is a half defined class and there is not point in creating a object of half a defined class. So you need to define a full implementation by creating a child class and you can then create the object of the child class.

Click here for 32 basic .NET interview questions and answers


Saturday, February 5, 2011

.NET Interview question 4 :- What is difference between out and ref in c#?

.NET Interview question 4 :- What is difference between out and ref in c#?


This is a great .NET Interview question and also very very confusing question. By default parameters are always passed by value to methods and functions.If you want to pass data byref then you can use either out or ref keyword.
There are two big difference between these keywords one is the way data is passed between the caller code and method and second who is responsible for initialization.

Way the data is passed(directional or bi-directional)
==============================================================

When you use OUT data is passed only one way i.e from the method to the caller code.

When you use REF , Data can be passed from the called to the method and also vice versa.

Who initializes data
==============================================================
In OUT the variables value has to be intialized in the method. In REF the value is initialized outside the method by the caller.


The most important thing the interviewer will like to hear from you
When to use when

==============================================================

OUT will be used when you want data to be passed only from the method to the caller.

REF will be used when you want data to be passed from the called to the method and also vice versa.


Click here to view 22 top .net interview questions

.Net Interview Questions -What is the difference between app.config, web.config and machine.config ?

.Net Interview Questions -What is the difference between app.config, web.config and machine.config ?


Answer:
In this .NET Interview question interviewer expects two things. First the importance of configuration and second in which scenarios are the above file applicable. So lets answer the question in two parts.

The importance of config files
==================================================

App.config, web.config and machine.config are files which store configuration
data in XML format. We need configuration data at application level or at machine/server level.

Scenarios in which the above config files are used===================================================

Machine.config file stores configuration information at system level. It can contain configuration information like timeout in ASP.NET application, requestLimit, memoryLimit, and ClientConnectedCheck etc.
Generally we have two kinds of application web application and windows application. Web.config file stores configuration data for web applications and app.config file store configuration information for windows application.
Application level configuration data can be like connection strings,security
etc.

Some connected questions from this question which the interviewer can
ask
================================================================================

Where do you store connection string ?.

How do you encrypt connection string?

How do you read configuration data from web.config or app.config file in .NET ?

Can we have two web.config files for a web application.
Regards,
Read my 40 other .NET Interview questions

Thursday, February 3, 2011

.NET Interview Questions - What is the difference between .NET 1.1,2.0,3.0,3.5 and 4.0 ?

.NET Interview Questions - What is the difference between .NET 1.1,2.0,3.0,3.5 and 4.0 ?

Answer: The list of differences are huge. In interviews you normally need to short and sweet. So we will list down top 5 differences from each section.
So lets first start with the difference between 1.0 and 2.0.

=========================

Support for 64 bit application.

Generics

SQL cache dependency

Master pages

Membership and roles


Now the next difference .NET 2.0 and 3.0

=========================

WCF

WPF

WWF

WCS ( card space)


3.0 and 3.5
=========================

LINQ

Ajax inbuilt

ADO Entity framework

ADO data services

Multi targeting


Finally 3.5 and 4.0
=========================

MEF

Parallel computing

DLR dynamic

Code contract

language runtime

Lazy initialization
Click the following link to view21 top .NET interview questions

Tuesday, February 1, 2011

Response.redirect and server.transfer ( .NET Interview questions)

Response.redirect and server.transfer (
.NET Interview questions)



This is one of the favorite questions in ASP.NET Interviews. Every interviewer would like to know from the .NET candidate two things, how they differ technically and which scenarios should we use them.
Technical difference :- In Response.Redirect the following steps happen :-

1 - Client browser sends a signal to the server that he wants to go to xyz.aspx.

2 - Server responds back to the browser about the location of xyz.aspx and tells the client to go to that location.

3- Client gets the response and redirects to xyz.aspx.
In server.transfer the the following step happens :-

1 - Client browser sends a signal to the server that he wants to go to xyz.aspx.

2 - Server redirects to xyz.aspx and send the output to the client.


In other words in response.redirect there is a round trip while in server.transfer there are no round trips.

The next question what interviewer will ask is so does that mean we should always use server.trasfer and response.redirect is never needed

Both of the are useful under different scenarios. Response.redirect is good when we want to go cross domains , in other words you want to redirect from http://www.questpond.com/ to http://www.microsoft.com/. Server.trasfer do not work when you go cross domains.
22 top important .NET interview questions

13 important .net interview questions on debugging and tracing

13 important .net interview questions on debugging and tracing


This section will cover the most asked .net interview questions by the interviewer so friends have a look on the following and do revise .net interview questions when ever you go for the interview.

Normally the .net interviewer starts with.....

What is Instrumentation?
What is debugging and tracing?
How can we implement debugging and tracing in ASP.NET ?
How do we view the results of debug and trace?
So can we see a quick sample of how tracing information can be viewed?
What if we want to enable tracing in all pages?
Is it possible to do silent tracing, rather than displaying on the
browser?

How do I persist the instrumented information?
There is too much noise can we only see information which we need?
All the above methodologies are for web, how can we do tracing for windows?
Can we emit different types of trace events like critical, warning, error
etc?

Can we control what kind of information can be routed?
How can switch off instrumentation?

You can also see 40 important .NET interview questions from this link.
So friends get answers to above questions on debugging and tracing of .net interview questions by clicking this link.