Sei sulla pagina 1di 14

Introduction

Hi, I hope you are all fine. If you are a .Net professional and if you are looking for a change in job (especially
in Infosys, IBM, DELL, Aversan) you may want to read: Interview Questions For 3 Year .NET Professionals.
Please read this article in my blog : http://sibeeshpassion.com/dot-net-interview-questions-for-experiencedand-fresher.html
I have described my interview experience there. Now I will share some other important series of questions
that will definitely ask in any .Net interview. What employers currently look for in a candidate is logical
understanding with basic knowledge. So understanding the basics is very important, even if you are an
experienced candidate.
So let us start. I hope you will like this article. Please provide your valuable comments so that I can improve
myself.
First of all you must be ready to introduce yourself. Please don't use so many mmmmm and And and
and. Be confident and don't urge. Take your own time to describe yourself. Look straight. You can find more
tips here: How to Prepare for a Job Interview.
Now we will concentrate on the technical questions.
Please note that these questions are asked in my interview experience, you may need to see more
questions when you go for your interview.
1. What is the sequence of execution of the ASP.NET page life cycle?
The simple way is to remember SILVER.

S (It is not counted)

I (Init)

L (Load)

V (Validate)

E (Event)

R (Render)

Read more here.


2. What is the difference between a Hash Table and a Dictionary?
The main differences are listed below.
Dictionary:

Returns an error if the key does not exist

No boxing and unboxing

Faster than a Hash table

Hashtable:

Returns NULL even if the key does not exist

Requires boxing and unboxing

Slower than a Dictionary

3. How to use View state?


1.

string str = "Sibeesh Passion";

2.

if(ViewState["SampleText"]==null)

3.

4.
5.

ViewState["SampleText"] = str;
}

4. What are the state management techniques used in .NET?


Client-side:

Hidden Field

View State

Cookies

Control State

Query Strings

Server-side:

Session

1. In Proc mode
2. State Server mode
3. SQL Server mode
4. Custom mode

Application.

Read here.
5. How can we create a new table in SQL with only the structure?
Here is the query to do that.
Select * Into<B>From<A>Where1 = 2
Points to be noted:

A is the source table.

B is the destination table.

The condition 1=2 is to prevent the data from being copyied.

6. How to add a button dynamically to a grid view?

1.

Button myButton = newButton();

2.

myButton.Text = "Hai";

3.

myGrid.Controls.Add(myButton);

7. How to find a control inside a GridView?


1.

Button btnTest = (Button) myGrid.Rows[0].Cells[1].Controls[1].FindControl("myButton ");

Here we are finding the control myButton from the 0th row first cell.
8. What are abstract and interface? Provide actual examples.
Please read here.
9. What is partial class?
There are the following situations of when splitting a class definition is desirable:

To work with large projects.

To split the class definitions as we needed with the keyword partial.

10. How to use a partial class?


1.

public partial class DailyExpenses

2.

3.

To make it more real, let us consider this class is used by the Husband .

4.

He will add his expenses (in programming life , his codes )

5.

public void AddExpensesByHus()

6.

7.

8.

9.

public partial class DailyExpenses

10. {
11.

To make it more real, let us consider this class is used by the Wife.

12.

She will add his expenses (in programming life , her codes )

13.

public void AddExpensesByWife()

14.

15.

16. }

11. How to remove a constraint from a table in SQL Server?


1.

ALTER TABLE MyTab DROP CONSTRAINT myConstraint

12. How to create Table Variables In T-SQL?


Normally the syntax to create a table variable is the same as to create a table statement.
1.

DECLARE@tabVar TABLE

2.

3.
4.

Your fields here


)

13. How can you delete a duplicate record from a table in SQL?
There are so many ways to do this. Here I am sharing what I use when I get that kind of situation.
I will create a temp table.
Copy the distinct data from the existing table to the temp table.
Empty the data in the existing table.
Insert the data from the temp table to the source table.
Here is the query to do that:
1. select distinct * into #tempTab From Address_Tab
2. delete from Address_Tab
3. insert into Address_Tab
4. select * from # tempTab
5. drop table # tempTab
14. When to use an override and new in C#?

We can use override when there is virtual/abstract/override type of method in base class.

We can use New when there is no virtual/abstract/override type of method in base class.

Introduction
Last week I attended an interview with Infosys, Chennai. When I entered the compound, there were very
many candidates. The atmosphere and culture in Infosys was very nice.
Please find the original article here : http://sibeeshpassion.com/Infosys-Interview-Questions-For-DotNetProfessionals.html
You can read another series of interview questions here : http://www.csharpcorner.com/UploadFile/65794e/dot-net-interview-questions-for-experienced-and-fresher/
Background
I have attended many interviews in my life. But the interview with Infosys was something different. I
thought to share that experience with you all.
Points to be remember

(There are some mistakes I made in the interview. I don't want you to do the same :) )
1. Please ensure that you are maintaining eye contact with the interviewer.
2. Be confident of what you say. Don't change your answer if the interviewer tries to make you do so.
3. Please avoid the unwanted examples.
4. Please never use any other technical terms that may provoke the interviewer into asking questions
about.
5. If you don't know the answer, please say "I don't know". It is always better to say so instead of going
with the wrong answer.
You can find more tips here: How to Prepare for a Job Interview
Questions asked and answers
(Here I am giving the answers that I answered .)
1. Tell me about yourself?
A. You can find many answers to this question in the internet. Please see the following link:
Tell me about yourself
2. What is your role in your project? What is the team size?
A. I said "My main role is coding, unit testing, big fixing and maintenance. My team size is 7".
3. What is the hierarchy of your team?
A. First I was confused by this question. Then I answered "Project Manager, Team Leader, Software
Engineers, Trainees".
4. Describe the projects that you have worked on?
A. I described them. Please include the technologies you used in your projects and what kind of architecture
(for example: 3-tire, n- tier) you used.
5. What is the employee size in your company? You don't need to be accurate. You can provide the
approximate value.
A. I said "150 to 200".
Then he moved to the programming section.
6. Write an algorithm and program to determine whether or not a word is a palindrome.
We can do it in either of the following two ways:
a) Using a built-in function as in the following:
1.

string strRev,strReal = null;

2.

Console.WriteLine("Enter the string..");

3.

strReal = Console.ReadLine();

4.

char[] tmpChar = strReal.ToCharArray();

5.

Array.Reverse(tmpChar);

6.

strRev=new string(tmpChar);

7.

if(strReal.Equals(strRev, StringComparison.OrdinalIgnoreCase))

8.

9.

Console.WriteLine("The string is pallindrome");

10. }
11. else
12. {
13.

Console.WriteLine("The string is not pallindrome");

14. }
15.

Console.ReadLine();

Ref: To check string is palindrome or not in .NET (C#)


b) Without using a built-in function.
When I wrote the first program, the interviewer asked me to write the same without using a built-in function.
1.
2.

private static bool chkPallindrome(string strVal)


{

3.

try

4.

5.

int min = 0;

6.

int max = strVal.Length - 1;

7.

while (true)

8.

9.

if (min > max)

10.

return true;

11.

char minChar = strVal[min];

12.

char maxChar = strVal[max];

13.

if (char.ToLower(minChar) != char.ToLower(maxChar))

14.

15.

return false;

16.

17.

min++;

18.

max--;

19.

20.

21.

catch (Exception)

22.

23.
24.

throw;

25.

26.

Ref: You can find more here: C# Palindrome


7. Write a program to determine the count of a specific character in a string.
A.
1.

using System;

2.

using System.Collections.Generic;

3.

using System.Linq;

4.

using System.Text;

5.
6.

namespace FindCountCharOccurance

7.

8.

class Program

9.

10.

static void Main(string[] args)

11.

12.

string strOccur,strChar = null;

13.

Console.WriteLine("Enter the string in which you need to find the count of a char occurance");

14.

strOccur = Console.ReadLine();

15.
16.

Console.WriteLine("Enter the char to be searched..");

17.

strChar = Console.ReadLine();

18.

int intCnt =strOccur.Length- strOccur.Replace(strChar, string.Empty).Length;

19.

Console.WriteLine("Count of occurance is "+intCnt);

20.

Console.ReadLine();

21.
22.

}
}

23. }

Please see this for more suggestions: count the number of characters in a string.
8. Next he gave me a program like the following and asked me what the output of this will be.
1.

public class A

2.

3.

public int A()

4.

5.

Console.WriteLine("Hi you are in class A");

6.

7.

A. I said "Here we have a constructor A; a constructor should not have a return type. So the code above will
throw a compilation error."
9. What may be the output of the following program?
1.

using System;

2.

using System.Collections.Generic;

3.

using System.Linq;

4.

using System.Text;

5.
6.

namespace RefClass

7.

8.

class Program

9.

10.

static void Main(string[] args)

11.

12.

B bObj= new B();

13.

Console.ReadLine();

14.
15.

16.

17.

public class A

18.

19.

public A()

20.

21.

Console.WriteLine("Hi you are in class A");

22.

23.

24.
25.

public class B:A

26.

27.

public B()

28.

29.

Console.WriteLine("Hi you are in class B");

30.

31.

32. }

A. I said the output will be:


Hi you are in class A
Hi you are in class B
Even though you are creating an object of the derived class, it will invoke the base class first.
10. Write the output of the following program.
1.
2.

class Program
{

3.

static void Main(string[] args)

4.

5.

B bObj= new B(2);

6.

Console.ReadLine();

7.
8.

9.

10.

public class A

11.

12.

public A()

13.

14.

Console.WriteLine("Hi you are in class A");

15.

16.
17.

public A(int x)

18.

19.
20.
21.

}
}

22.
23.

public class B:A

24.

25.

public B()

26.

27.

Console.WriteLine("Hi you are in class B");

28.
29.

}
}

A. It will throw a compilation error.


B does not contain a constructor that takes 1 argument. If you want to make this program run, you must
create a parameterized constructor for class B also.
11. Abstract and interface real time examples
B.Please read it here: Real time example of interface
12. Describe authentication, types, differences?
A. Forms, Windows, Passport. Please read more here: ASP.NET authentication and authorization
13. Why DBMS? Why don't we save data in separate files?
A. I didn't know what exactly he meant, I got stuck there for a while. Finally I came up with the answer that
"Normalization" is the main advantage of a DBMS.
Read more here: Why use a DBMS?
14. What is the differences between a Primary key and a Unique key?
A. Primary key doesn't allow NULL, a unique key does.
15. What exactly is happening when we make a field a primary key?
A. A clustered index will be created for that specific field.
16. How may clustered index we can create in table?
A. Basically we can create only one clustered index, but there is a way to have more. Please read here: Only
one clustered index can be created on table <Tablename>. (Visual Database Tools)
17. What is the difference between a clustered and a non-clustered index?

A. I explained, please read here: Clustered and Non-Clustered Index in SQL 2005
18. What is a Distributed System?
A. A collection of autonomous computers.
http://www.csc.villanova.edu/~schragge/CSC8530/Intro.html

Image Courtesy : http://msdn.microsoft.com/en-us/library/cc239737.aspx


19. What will be the output for the below mentioned lines in JQuery?

1.

alert('5' + 5 + 5);

2.

alert(5 + 5 + '5');

3.

alert(5 + '5' + '5');

4.

alert(5 + '5' );

That was little tricky at that time. For a while I thought, and I just wrote the question to a paper, and replied.

1.

alert('5' + 5 + 5);

Output= 555

2.

alert(5 + 5 + '5');

Output=105

3.

alert(5 + '5' + '5'); Output=555

4.

alert(5 + '5' );

Question.1

Output=55

What are implementation inheritance and interface inheritance?

Answer: Implementation inheritance is achieved when a class is derived from another class in
such a way that it inherits all its members. Interface inheritance is when a class inherits only the
signatures of the functions from another class.
Question.2 What are generics in C#.NET?
Answer: Generic types to maximize code reuse, type safety, and performance. They can be used
to create collection classes. Generic collection classes in the System.Collections.Generic namespace
should be used instead of classes such as ArrayList in the System.Collections namespace.
Question.3

What is the use of GetCommandLineArgs() method in C#.NET?

Answer:
With GetCommandLineArgs() method, the command line arguments can be accessed.
The value returned is an array of strings.
Question.4

What is the use of System.Environment class in C#.NET?

Answer: The System.Environment class can be used to retrieve information like command-line
arguments, the exit code, environment variable settings, contents of the call stack, time since last
system boot, the version of the common language runtime.
Question.5

What is an Exception in .NET?

Answer: Exceptions are errors that occur during the runtime of a program. The advantage of using
exceptions is that the program doesnt terminate due to the occurrence of the exception. Whenever an
exception is occurred the .NET runtime throws an object of specified type of Exception. The class
Exception is the base class of all the exceptions..
Question.6

What are Custom Exceptions?

Answer: Custom Exceptions are user defined exceptions.


Question.7

What is a Constructor?

Answer: It is the first method that are called on instantiation of a type. It provides way to set default
values for data before the object is available for use. Performs other necessary functions before the
object is available for use.
Question.8 Can private virtual methods be overridden in C#.NET?
Answer: No, moreover, you cannot access private methods in inherited classes. They have to be
protected in the base class to allow any sort of access.
Question.9 Is is possible to force garbage collector to run?
Answer: Yes, we can force garbage collector to run using System.GC.Collect().
Question.10

What is an Event?

Answer: When an action is performed, this action is noticed by the computer application based on
which the output is displayed. These actions are called events. Examples of events are pressing of the
keys on the keyboard, clicking of the mouse. Likewise, there are a number of events which capture
your actions.
Question.11

What is Delegate?

Answer: Delegates are kind of similar to the function pointers. But they are secure and type-safe. A
delegate instance encapsulates a static or an instance method. Declaring a delegate defines a
reference type which can be used to encapsulate a method having a specific signature.
Question.12

How does object pooling and connection pooling differ?

Answer: In Object pooling, you can control the number of connections. In connection pooling, you
can control the maximum number reached. When using connection pooling, if there is nothing in the
pool, a connection is created since the creation is on the same thread. In object pooling, the pool
decides the creation of an object depending on whether the maximum is reached which in case if it is,
the next available object is returned. However, this could increase the time complexity if the object is
heavy.
Question.13 What is Language Integrated Query (LINQ)?
Answer: LINQ is a set of extensions to .NET Framework that encapsulate language integrated
query, set and other transformation operations. It extends VB, C# with their language syntax for
queries. It also provides class libraries which allow a developer to take advantages of these features.
Question.14
contains it?

Explain

the

purpose of CultureInfo

class.

What

namespace

Answer:
System.Globalization namespace contains CultureInfo class. This class provides
information about a specific culture, i.e. datetime format, currency, language etc.
Question.15

Which is the class from where everything is derived in .NET?

Answer: System.Object. Object class is the ultimate base class of all classes in the .NET
Framework, it is the root of the type hierarchy. It is often used as a generic argument in class methods
all classes are treatable as Object classes.
Question.16

What is the use of assert() method?

Answer: Assert method is in debug compilation. It takes a boolean condition as a parameter. It


shows error dialog if the condition is false and if the condition is true, the program proceeds without
interruption.
Question.17 Difference
System.Array.Clone()?

between

the

System.Array.CopyTo()

and

Answer: System.Array.CopyTo() performs a deep copy of the array. System.Array.Clone() performs


a shallow copy of the array

Question.18 What is the purpose of Dispose method?


Answer: Dispose method is used to destroy the objects from the memory.
Question.19 What is the difference between shadow and override?
Answer: In general when you extend a class you shadow fields with the same name in the base
class and override virtual methods with the same name and parameter list in the base class.
Overriding makes the base class method invisible. Shadowing a field only hides the field from view.
You can still explicitly touch the hidden shadowed field if you wish. You cannot touch an invisible
overridden method.

Potrebbero piacerti anche