0% found this document useful (0 votes)
42 views22 pages

Interview Questions C#

This document provides tips for job interviews, including maintaining eye contact, being confident in your answers, avoiding unwanted examples, not using unnecessary technical terms, and admitting when you don't know an answer rather than guessing. It also provides tips for answering common interview questions like "tell me about yourself" by focusing on qualifications for the position, and "why are you leaving your current company" by focusing on desires for new challenges and professional growth. Sample answers to these questions are also provided.

Uploaded by

Akash Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views22 pages

Interview Questions C#

This document provides tips for job interviews, including maintaining eye contact, being confident in your answers, avoiding unwanted examples, not using unnecessary technical terms, and admitting when you don't know an answer rather than guessing. It also provides tips for answering common interview questions like "tell me about yourself" by focusing on qualifications for the position, and "why are you leaving your current company" by focusing on desires for new challenges and professional growth. Sample answers to these questions are also provided.

Uploaded by

Akash Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 22

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.

Tell me about yourself.


Tips to remember :
♦ First of all think about What I Want To Hear If I Ask You To Tell Me About Yourself
♦ Start with the present and tell why you are well qualified for the position.
♦ Best to start with a strong simple statement about yourself (again related to the job
and type of person they’re looking for) and expand with a synthesized work history
that shows how miraculously everything you’ve done up to now has led you to this
precise moment and prepared you perfectly for this job!

Q. Why are you leaving this company?


Firstly I actually been associated with my current organization with more than one and half
year now I am realizing my learning process and professional knowledge have come to a
standstill point though I want to increase my role and job responsibilities to meet new
challenges so decided to associate with highly skillful capable and experienced professional
that help me professionally and financially as well in future.

Secondly when I was out from college I want to be a software developer because I love
coding/programming. But in this company they are giving me designation of assistant of
project manager i.e. I am going to manage a team not to coding full time. So to be a successful
software developer I decided to leave this company.

Q. Tell me about yourself.


Good morning Sir,
First of all I would like to thank you, for giving me an opportunity to introduce myself.
My self Hitesh Chauhan, I belong from Ghaziabad.
Presently I am working in Nevitech Data solutions Pvt. Ltd. as software developer since 1 Ag
2013. I have experienced there about 1.10 years.
I am MCA passed having 71% from Hitech Institute of Technology .

I did my BCA from CCS university having 67% from Mewar Institute of Management.
I did my 12th from CBSE Board with 60% & 10th from CBSE Board with 67%.

I like computer, Because In my schooling days, I have scored High marks in that subject
compared to Maths, physics.

My Hobbies is playing cricket, A Passion for teaching kids.


My Strength is takes Initiative to work independently, Good leadership skill, Adaptable to any
kind of situation in estranged group & Helping tendency.
My Weakness is I am not comfortable, until I finish my work in the given time & over friendly
in nature.
My Short term goal is to get the job in reputed company.
My Long term goal is to become more responsible and knowledgeable personality and on
respectable position on my company.
That's all about me!
Thank you very much for giving a great opportunity to introduce myself behind you.

Q. What is your role in your project? What is the team size?

My main role is coding, unit testing, bug fixing and maintenance. My team size is 7".

Q. What is the hierarchy of your team?

There is a Project Manager, Team Leader, Software Engineers and Trainees.

Q. Describe the projects that you have worked on?

My Project Exam Management & Result Processing System has ADO.NET and ASP.NET
Technology. It includes Crystal Reports and RDLC Reports. My project is based on 2-tier
architecture.

Two-Tier Architecture:
The two-tier is based on Client Server architecture. The two-tier architecture is like client
server application. The direct communication takes place between client and server. There is
no intermediate between client and server. Because of tight coupling a 2 tiered application
will run faster.

Two-Tier Architecture
The above figure shows the architecture of two-tier. Here the direct communication between
client and server, there is no intermediate between client and server.
Let’s take a look of real life example of Railway Reservation two-tier architecture:
Let’s consider that first Person is making Railway Reservation for Mumbai to Delhi by Mumbai
Express at Counter No. 1 and at same time second Person is also try to make Railway
reservation of Mumbai to Delhi from Counter No. 2
If staff from Counter No. 1 is searching for availability into system & at the same staff from
Counter No. 2 is also looking for availability of ticket for same day then in this case there is
might be good change of confusion and chaos occurs. There might be chance of lock the
Railway reservation that reserves the first.
But reservations can be making anywhere from the India, then how it is handled?
So here if there is difference of micro seconds for making reservation by staff from Counter
No. 1 & 2 then second request is added into queue. So in this case the Staff is entering data to
Client Application and reservation request is sent to the database. The database sends back
the information/data to the client.
In this application the Staff user is an end user who is using Railway reservation application
software. He gives inputs to the application software and it sends requests to Server. So here
both Database and Server are incorporated with each other, so this technology is called as
“Client-Server Technology“.
The Two-tier architecture is divided into two parts:
1) Client Application (Client Tier)
2) Database (Data Tier)
On client application side the code is written for saving the data in the SQL server
database. Client sends the request to server and it process the request & send back with data.
The main problem of two tier architecture is the server cannot respond multiple request same
time, as a result it cause a data integrity issue.
Advantages:
1. Easy to maintain and modification is bit easy
2. Communication is faster
Disadvantages:
1. In two tier architecture application performance will be degrade upon increasing the
users.
2. Cost-ineffective
Three-Tier Architecture:
Three-tier architecture typically comprise a presentation tier, a business or data access tier,
and a data tier. Three layers in the three tier architecture are as follows:
1) Client layer
2) Business layer
3) Data layer
1) Client layer:
It is also called as Presentation layer which contains UI part of our application. This layer is
used for the design purpose where data is presented to the user or input is taken from the
user. For example designing registration form which contains text box, label, button etc.
2) Business layer:
In this layer all business logic written like validation of data, calculations, data insertion etc.
This acts as a interface between Client layer and Data Access Layer. This layer is also called
the intermediary layer helps to make communication faster between client and data layer.
3) Data layer:
In this layer actual database is comes in the picture. Data Access Layer contains methods to
connect with database and to perform insert, update, delete, get data from database based on
our input data.
Three-tier Architecture
Advantages
1. High performance, lightweight persistent objects
2. Scalability – Each tier can scale horizontally
3. Performance – Because the Presentation tier can cache requests, network utilization is
minimized, and the load is reduced on the Application and Data tiers.
4. High degree of flexibility in deployment platform and configuration
5. Better Re-use
6. Improve Data Integrity
7. Improved Security – Client is not direct access to database.
8. Easy to maintain and modification is bit easy, won’t affect other modules
9. In three tier architecture application performance is good.
Disadvantages
1. Increase Complexity/Effort
Q. What is the employee size in your company? You don't need to be accurate. You can provide
the approximate value.

A. 20 to 30.
Q. 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();
b) Without using a built-in function.

private static bool chkPallindrome(string strVal)


1. {
2. try
3. {
4. int min = 0;
5. int max = strVal.Length - 1;
6. while (true)
7. {
8. if (min > max)
9. return true;
10. char minChar = strVal[min];
11. char maxChar = strVal[max];
12. if (char.ToLower(minChar) != char.ToLower(maxChar))
13. {
14. return false;
15. }
16. min++;
17. max--;
18. }
19. }
20. catch (Exception)
21. {
22.
23. throw;
24. }
25. }
Q. Write a program to determine the count of a specific character in a string.

using System;
1. using System.Collections.Generic;
2. using System.Linq;
3. using System.Text;
4.
5. namespace FindCountCharOccurance
6. {
7. class Program
8. {
9. static void Main(string[] args)
10. {
11. string strOccur,strChar = null;
12. Console.WriteLine("Enter the string in which you need to find the count of a char
occurance");
13. strOccur = Console.ReadLine();
14.
15. Console.WriteLine("Enter the char to be searched..");
16. strChar = Console.ReadLine();
17. int intCnt =strOccur.Length- strOccur.Replace(strChar, string.Empty).Length;
18. Console.WriteLine("Count of occurance is "+intCnt);
19. Console.ReadLine();
20. }
21. }
22. }

Q. 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. }
Here we have a constructor A; a constructor should not have a return type. So the code above
will throw a compilation error."

Q. 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. }
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.
Q. Write the output of the following program.
1. class Program
2. {
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. }
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.
Q. Abstract and interface real time examples

Do you mean real-world as in "A live software system which includes Abstract classes or
interfaces" or do you mean "A contrived example which demonstrates their usefullness"?
If you mean the latter think of Vehicle as an abstract class. You can't yet do anything with it
because you have no idea what it does, or how to drive it.
abstract class Vehicle{}
Vehicles could be split into morotized and pedal-powered, but still this is abstract, we still
dont know what to do with it.
abstract class MotorVehicle : Vehicle {}
abstract class PedaledVehicle : Vehicle {}
You could now define a concrete (non-abstract) class, like car.
class MotorCar : MotorVehicle {}
Intefaces come in handy you can only inherit from one base class. So imagine some vehicles
are drivable, others are remote controlled, some vehicles use a stearing wheel, others dont
interface IDrivable{}
interface IHasStearingWheel{}
Now you could derive a DrivableMotorCar from its base clas, and also implement other
behaviours.
class DrivableMotorCar : MotorVehicle, IDrivable, IHasStearingWheel {}
Q. Describe authentication, types, differences?

Q. Why DBMS? Why don't we save data in separate files?

"Normalization" is the main advantage of a DBMS.

Q. What is the differences between a Primary key and a Unique key?

A. Primary key doesn't allow NULL, a unique key does.

Q. What exactly is happening when we make a field a primary key?

A. A clustered index will be created for that specific field.

Q. How may clustered index we can create in table?

Basically we can create only one clustered index, but there is a way to have more

Q. What is the difference between a clustered and a non-clustered index?

Q. What is a Distributed System?

A. A collection of autonomous computers.


1.2.2.3 Distributed Systems Model
Traditionally, having software run across multiple computers meant splitting the software
into separate client and server components. In such systems, the client component handled
the user interface and the server provided back-end processing, such as database access,
printing, and so on.
As computers proliferated, dropped in cost, and became connected by ever higher bandwidth
networks, splitting software systems into multiple components became more convenient,
with each component running on a different computer and performing a specialized function.
This approach simplified development, management, administration, and often improved
performance and robustness because failure in one computer did not necessarily disable the
entire system.
In many cases the system appears to the client as an opaque cloud that performs the
necessary operations, even though the distributed system is composed of individual nodes, as
illustrated in the following figure.

Figure 3: Distributed system paradigm


The opacity of the cloud is maintained because computing operations are invoked on behalf of
the client. As such, clients can locate a computer (a node) within the cloud and request a
particular operation; in performing the operation, that computer can invoke functionality on
other computers within the cloud without exposing the additional steps, or the computer on
which they were carried out, to the client.
With this paradigm, the mechanics of a distributed, cloud-like system can be broken down
into many individual packet exchanges, or conversations between individual nodes.
Traditional client/server systems have two nodes with fixed roles and responsibilities.
Modern distributed systems can have more than two nodes, and their roles are often dynamic.
In one conversation, a node can be a client; while in another conversation, the node can be the
server. In many cases, the ultimate consumer of the exposed functionality is a client with a
user sitting at a keyboard and watching the output. In other cases the distributed system
functions unattended, performing background operations.
The distributed system may not have dedicated clients and servers for each particular packet
exchange, but it is important to remember that there is a caller (or initiator), often referred to
as the client. There is also the recipient of the call (often referred to as the server). It is not
necessary to have two-way packet exchanges in the request-reply format of a distributed
system; often messages are sent only one way.
Q. 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' );

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' ); Output=55

Q. What is ADO.NET
Ans. ADO. NET is a technology or as a set of classes in framework that can be used to interact
with data sources like Database and XML Files or such files where we can kept data in tabular
format. This data can be consumed in any .NET application.
ADO.NET i.e. Microsoft ActiveX Data Objects.
By using ADO.NET we can connect a database, execute commands and retrieve data.

.NET Data Providers :


Sql Server : System.Data.SqlClient
Oracle : System.Data.OracleClient
OleDb : System.Data.OleDb
Odbc : System.Data.Odbc

Q. What is connection string


Ans. Connection string is a set of information by which we can connect to database.
Connection string contains
Data Source=Server1\SqlServer ;
Initial Catalog=CSJM1503 ;
UID=sa ;
Password=pass2010@;
Integrated Security=SSPI

Q. Pillars of Object Oriented Programming


Ans. 1. Encapsulation
2. Polymorphism
3. Inheritance

Q. What is Inheritence
Ans. Inheritance, together with encapsulation and polymorphism, is one of the three primary
characteristics (or pillars) of object-oriented programming. Inheritance enables you to create
new classes that reuse, extend, and modify the behavior that is defined in other classes. The
class whose members are inherited is called the base class, and the class that inherits those
members is called the derived class. A derived class can have only one direct base class.
However, inheritance is transitive. If ClassC is derived from ClassB, and ClassB is derived from
ClassA, ClassC inherits the members declared in ClassB and ClassA.
Note
Structs do not support inheritance, but they can implement interfaces.
Conceptually, a derived class is a specialization of the base class. For example, if you have a base
class Animal, you might have one derived class that is named Mammal and another derived
class that is named Reptile. A Mammal is an Animal, and a Reptile is an Animal, but each
derived class represents different specializations of the base class.
When you define a class to derive from another class, the derived class implicitly gains all the
members of the base class, except for its constructors and destructors. The derived class can
thereby reuse the code in the base class without having to re-implement it. In the derived
class, you can add more members. In this manner, the derived class extends the functionality
of the base class.
Example
// WorkItem implicitly inherits from the Object class.
public class WorkItem
{
// Static field currentID stores the job ID of the last WorkItem that
// has been created.
private static int currentID;

//Properties.
protected int ID { get; set; }
protected string Title { get; set; }
protected string Description { get; set; }
protected TimeSpan jobLength { get; set; }

// Default constructor. If a derived class does not invoke a base-


// class constructor explicitly, the default constructor is called
// implicitly.
public WorkItem()
{
ID = 0;
Title = "Default title";
Description = "Default description.";
jobLength = new TimeSpan();
}

// Instance constructor that has three parameters.


public WorkItem(string title, string desc, TimeSpan joblen)
{
this.ID = GetNextID();
this.Title = title;
this.Description = desc;
this.jobLength = joblen;
}

// Static constructor to initialize the static member, currentID. This


// constructor is called one time, automatically, before any instance
// of WorkItem or ChangeRequest is created, or currentID is referenced.
static WorkItem()
{
currentID = 0;
}

protected int GetNextID()


{
// currentID is a static field. It is incremented each time a new
// instance of WorkItem is created.
return ++currentID;
}

// Method Update enables you to update the title and job length of an
// existing WorkItem object.
public void Update(string title, TimeSpan joblen)
{
this.Title = title;
this.jobLength = joblen;
}

// Virtual method override of the ToString method that is inherited


// from System.Object.
public override string ToString()
{
return String.Format("{0} - {1}", this.ID, this.Title);
}
}

// ChangeRequest derives from WorkItem and adds a property (originalItemID)


// and two constructors.
public class ChangeRequest : WorkItem
{
protected int originalItemID { get; set; }

// Constructors. Because neither constructor calls a base-class


// constructor explicitly, the default constructor in the base class
// is called implicitly. The base class must contain a default
// constructor.

// Default constructor for the derived class.


public ChangeRequest() { }
// Instance constructor that has four parameters.
public ChangeRequest(string title, string desc, TimeSpan jobLen,
int originalID)
{
// The following properties and the GetNexID method are inherited
// from WorkItem.
this.ID = GetNextID();
this.Title = title;
this.Description = desc;
this.jobLength = jobLen;

// Property originalItemId is a member of ChangeRequest, but not


// of WorkItem.
this.originalItemID = originalID;
}
}

class Program
{
static void Main()
{
// Create an instance of WorkItem by using the constructor in the
// base class that takes three arguments.
WorkItem item = new WorkItem("Fix Bugs",
"Fix all bugs in my code branch",
new TimeSpan(3, 4, 0, 0));

// Create an instance of ChangeRequest by using the constructor in


// the derived class that takes four arguments.
ChangeRequest change = new ChangeRequest("Change Base Class Design",
"Add members to the class",
new TimeSpan(4, 0, 0),
1);

// Use the ToString method defined in WorkItem.


Console.WriteLine(item.ToString());

// Use the inherited Update method to change the title of the


// ChangeRequest object.
change.Update("Change the Design of the Base Class",
new TimeSpan(4, 0, 0));

// ChangeRequest inherits WorkItem's override of ToString.


Console.WriteLine(change.ToString());

// Keep the console open in debug mode.


Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
/* Output:
1 - Fix Bugs
2 - Change the Design of the Base Class
*/

Q.

Q. What is interface
Ans. An interface is a reference type that is somewhat similar to an abstract base class that
consists of only abstract members. When a class implements an interface, it must provide an
implementation for all the members of the interface. A class can implement multiple
interfaces even though it can derive from only a single direct base class.
Interfaces are used to define specific capabilities for classes that do not necessarily have an "is
a" relationship. For example, the System.IEquatable<T> interface can be implemented by any
class or struct that has to enable client code to determine whether two objects of the type are
equivalent (however the type defines equivalence). IEquatable<T> does not imply the same
kind of "is a" relationship that exists between a base class and a derived class (for example, a
Mammal is an Animal).

Q. What is abstract class


Ans. You can declare a class as abstract if you want to prevent direct instantiation by using the
new keyword. If you do this, the class can be used only if a new class is derived from it. An
abstract class can contain one or more method signatures that themselves are declared as
abstract. These signatures specify the parameters and return value but have no
implementation (method body). An abstract class does not have to contain abstract members;
however, if a class does contain an abstract member, the class itself must be declared as
abstract. Derived classes that are not abstract themselves must provide the implementation
for any abstract methods from an abstract base class.

Q. What are Abstract & Virtual functions


Ans. When a base class declares a method as virtual, a derived class can override the method
with its own implementation. If a base class declares a member as abstract, that method must
be overridden in any non-abstract class that directly inherits from that class. If a derived class
is itself abstract, it inherits abstract members without implementing them. Abstract and
virtual members are the basis for polymorphism, which is the second primary characteristic
of object-oriented programming.

Q. What is Derived Class Access to Base Class Members


Ans. A derived class has access to the public, protected, internal, and protected internal
members of a base class. Even though a derived class inherits the private members of a base
class, it cannot access those members. However, all those private members are still present in
the derived class and can do the same work they would do in the base class itself. For
example, suppose that a protected base class method accesses a private field. That field has to
be present in the derived class for the inherited base class method to work correctly.

Q. How to Preventing Further Derivation


Ans. A class can prevent other classes from inheriting from it, or from any of its members, by
declaring itself or the member as sealed.
Q. What is Derived Class Hiding of Base Class Members
Ans. A derived class can hide base class members by declaring members with the same name
and signature. The new modifier can be used to explicitly indicate that the member is not
intended to be an override of the base member. The use of new is not required, but a compiler
warning will be generated if new is not used.

Q. Is multiple inheritance in .net


Ans.
what is dynamic polymorphism
what is difference between string builder class and string class
what is difference between data table and data view
how to sort a data table
how to select 10 data from a data table
what is namespace
what is an assembly name any buit in .net assembly
what is authentication and authorization
what is future of your project
what is your role in your project
what is the architecture of your project
what does if we make a class as private

What is .net Framework


What are the components of .Net Framework
What is the main role of CLR in .Net
What is valuetype and object type
what is the difference between c# and VB
on which situation you find the type casting is difficult in c# than VB
what is difference between stored procedure and function
what is the difference between c# and VB
can we use transactions in functions
Type Casting in C#.Net and VB.Net
how we declare constructor in c# and VB
what is sealed class
what is the differrence between sealed class and static class
what is the difference between interface and abstract class
how many constraints are in sql server
Output variable in stored procedure
Why we use group by clause and having clause

Q. What is indexing ?
Ans. Indexing means numbering of data where data is arranged by SQL Server in the form of
extents and pages. Each extent is of size 64 KB, having 8 pages of 8KB sizes. An extent may
have data from multiple or same table, but each page holds data from a single table only.
Logically, data is stored in record sets in the table. We have fields (columns) identifying the
type of data contained in each of the record sets. A table is nothing but a collection of record
sets; by default, rows are stored in the form of heaps unless a clustered index has been
defined on the table, in which case, record sets are sorted and stored on the clustered index.
The heaps structure is a simple arrangement where the inserted record is stored in the next
available space on the table page.
There are two types of indexs in Sql Server
1. Clustered Index
2. Non Clustered Index

But everything comes at a cost; the price we pay for having an index on the table is, each time
there is an Insert/Update/Delete, SQL Server updates the active indexes on the table where
these DML are operated. Hence simply creating indexes madly for the sake of better data
retrieval will not serve the purpose. If there are 20 indexes on a table, each time a DML is
done on the table, all these 20 indexes shall be updated so that they can uniquely figure out
the location of the record.

Clustered Index : A clustered index is something that reorganizes the way records in the table
are physically stored. Therefore a table can have only one clustered index. The leaf nodes of a
clustered index contain the data pages, by which I mean the key-value pair in the clustered
index has the index key and the actual data value. Also remember, a clustered index will be
created on a table by default the moment a primary key is created on the table. A clustered
index is something like your train ticket B4/24, you know that you need to board coach B4
and sit on seat number 24. So this index physically leads you to your actual seat.
CREATE CLUSTERED INDEX CL_ID ON SALES(ID);
Non Clustered Index : A non-clustered index is a special type of index in which the logical
order of the index does not match the physical stored order of the rows on disk. The leaf node
of a non-clustered index does not consist of the data pages but a pointer to it. That goes to say
that a non-clustered index can’t survive on its own - it needs a base to live on. A non-clustered
index uses a clustered index (if defined) or the heap to build itself.
When a non-clustered index uses the heap, the leaf node (or the pointer) is a physical location
of the data. When it uses a clustered index, the leaf node (or the pointer) is the clustered index
key value and this key value in turn points to the actual data.
CREATE NONCLUSTERED INDEX NONCI_PC ON SALES(ProductCode);

In an interview, I was asked: Once we declare a primary key, a clustered index is created on the
column by default; what if I wish to create a clustered index and a primary key on two different
columns? Is it possible?
It is very much possible to have two different columns as primary key and clustered indexes.
But remember, if I create a Primary Key on a table first, a CI will also be created. Now, in case I
need them on two different columns, drop the Primary Key constraint and the CI shall
automatically vanish. Now create a CI on column A and declare column B as Primary Key, and
column B will have a NCI created by default on it instead of a CI. This way, we can have two
columns as Primary Key and CI declared on them.
Q. What is a stored procedure ?
Ans. A stored procedure is a compiled set of Transact-SQL statements.
The business logic can be encapsulated using stored procedure.
It improves network traffic by running set of Transact-SQL statements at one go.
Stored procedure is a set of SQL commands that have been complied and stored on the
database sever. They can be used in the code as and when required since hey stored. They
need not be complied over and over again. They can be invoked by CALL procedure (..) or
EXECUTE procedure(..)
Q. Define extended Stored Procedures.
An extended stored procedure compiles as DLL and are created to expand capabilties of
user defined stored procedure. It uses xp_ prefix as naming convention.
Q. What are the purposes and advantages stored procedure?
Answer
Purposes and advantages of stored procedures:
 Manage, control and validate data
 It can also be used for access mechanisms
 Large queries can be avoided
 Reduces network traffic since they need not be recompiled
 Even though the stored procedure itself may be a complex piece of code, we need
not write it over and over again. Hence stored procedures increases reusability
of code
 Permissions can be granted for stored procedures. Hence, increases security.
Determine when to use stored procedure to complete SQL Server tasks.
Answer
 If a large piece of code needs to be performed repeatedly, stored procedures are
ideal
 When hundreds of lines of SQL code need to be sent; it is better to use stored
procedure through a single statement that executes the code in a procedure,
rather than by sending hundreds of lines of code over the network.
 When security is required.
 Stored Procedre:

 Stored Procedure is a group of sql statements that has been created once and stored in
server database. It’s pre-compile objects which are compiled for first time and its
compiled format is saved which executes (compiled code) whenever it is called. Stored
procedures will accept input parameters so that single stored procedure can be used
over network by multiple clients using different input data. Stored procedures will
reduce network traffic and increase the performance. (Read more Here)

 Function:

 Function is not pre-compiled object it will execute every time whenever it was called.

 Difference between Stored Procedure and Function

 1) Procedure can return zero or n values whereas function can return one value which
is mandatory (Read more Here).

 2) Procedures can have input, output parameters for it whereas functions can have
only input parameters.

3) Procedure allows select as well as DML(INSERT/UPDATE/DELETE) statements in it
whereas function allows only select statement in it.

4) Functions can be called from procedure whereas procedures cannot be called from
function.

5) Exception can be handled by try-catch block in a procedure whereas try-catch block
cannot be used in a function.

6) We can go for transaction management in procedure whereas we can't go in
function.

7) Procedures cannot be utilized in a select statement whereas function can be
embedded in a select statement.

1.What is GAC ??
2.What is Assembly?
3.How to place DLL in GAC??
4.What is pobm with DLL??
5.What is appSettings ??in webconfig>
6.What is tag in webconfig?
7.Property?.when Master page loads in Which Event?User Control and custom control ??

8.Why interface??
9.what is ajax?how it works with example
10.validate textbox with email using jquery
11.what is Delegate???why ??example.realtime
12.Diffrence between datareader and dataset??
13.which function for execution of query?in .net
14.how many tables can be in Dataset?
15.Main class in dot net ?which contains all clasees.
16 In Ajax will page redirect ??will it go to server for procees?

17.What is ViewState???Why >>>??real time Scenario?>


18.what is exception?object is not with the refrence?
19.If UserControl is used in web page then if 1 button in usercontrol if we click then that value
in textbox of user control should go to web page text box.and Vice a versa.??
20.what are Validators??if they are client side then if i disable the javascript in my browser
and in page there are 100 text box with validations then if i forgot to fill one textbox what will
happen page will redirect or not??
21.if not then which function we can use on server side to check all boxes are valid ??
22.How to put Checkbox in Gridview??by button and code?
23.stored Procedure ??if there are two statements in Procedure then how can we take both
result set in datareader?
Q. What is the difference between Server.Transfer and Response.Redirect?

In Server.Transfer page processing transfers from one page to the other page without making
a round-trip back to the client’s browser. This provides a faster response with a little less
overhead on the server. The clients url history list or current url Server does not update in
case of Server.Transfer.

Response.Redirect is used to redirect the user’s browser to another page or site. It performs
trip back to the client where the client’s browser is redirected to the new page. The user’s
browser history list is updated to reflect the new address.

Q. Pillar of OOPS
 Ans. 1 Pillars of Object Oriented Programming
 2 Major Pillars
o 2.1 1 Abstraction
o 2.2 2 Encapsulation
o 2.3 3 Modularity
o 2.4 4 Hierarchy
o 2.5 Polymorphism
 3 Minor Pillars
o 3.1 1 Concurrency
o 3.2 2 Persistence

Pillars of Object Oriented Programming

The features which make the language ‘Object Oriented Language’, are called the Pillars of Object
Oriented Programming.

Pillars Of Object Oriented Programming

Major Pillars
1 Abstraction
 Getting only essential things and hiding unnecessary details is called abstraction.
 It is the public access region of the class.
 Generally, it declares the operations that can be invoked by the clients on object of
class.
 Avoid using data members in public region of class, as it may be directly changes by the
client.
Example of Abstraction in c++

2 Encapsulation
 Binding of data and code together is called encapsulation.
 Encapsulation maintains integrity of object.
 For example, the Man class has a walk() method. The code for the Walk() method
defines exactly how a walk happens.
 The encapsulation is most often achieved through information hiding.
 Information hiding is the process of hiding all the secrets of an object that do not
contribute to its essential characteristics; typically,structure of an object is hidden, as
well as implementation of its methods.

3 Modularity
 The act of portioning a program into individual components can reduce its complexity
to some degree.
 Modularity can be physical modularity(e.g. divide program into .h, .cpp, .rc files) or
logical modularity(e.g. namespace)
 Modularization consists of dividing program into modules that can be compiled
seperately, but which are interconnected.
 Modularity helps in easier maintenance of a complex software.

4 Hierarchy

Hierarchy is ranking or ordering of abstractions.


Main purpose of hierarchy is to achieve re-usability.
The hierarchies are:
1. Inheritance (is-a relationship):

Acquiring all the properties(data members) and behaviors of one class by another class is called
inheritance.

Class Diagram-Inheritance
2. Composition (has-a relationship):

When object is madhe from other small objects it is called composition.

Class Diagram-Composition

A is owner of B and B is non shareable.

3. Aggregation (has-a relationship):

Class Diagram-Aggregation

A has B, A is owner of B, and B is shareable.

4. Aggregation (work-for relationship):

 Two objects works together for long time.


 It is bidirectional relationship
 In association, both are independent entities but just working together for long
duration.

Class Diagram-Association

5. Dependency (use-a relationship):

 Sometimes the relationship between two classes is very weak.


 They are not implemented with member variables at all.
 Rather they might be implemented as member function arguments.
Class Diagram-Dependency

Polymorphism

It is Greek word which is a combination of poly(many) + morphism(forms/behavior).


One interface having many behaviors such phenomenon is called polymorphism.

Types of polymorphism:

1. Compile time polymorphism:

 It is also called as static polymorphism, false polymorphism, early binding.


 When call to functions is resolved at compile time it is called compile time
polymorphism.
 In c++, Compile time polymorphism is achieved by using function overloading and
operator overloading.

2. Run time polymorphism:

 It is also called as dynamic polymorphism, true polymorphism or late binding.


 When call to the function resolved at run time, it is called run time polymorphism.
 In c++, run time polymorphism is achieved by using function overriding.

Minor Pillars
1 Concurrency
 The concurrency problem arises when multiple threads simultaneously access same
object.
 We may use a class library for providing threading support.
 We may use interrupts to give illusion of concurrency which need hardware details.
 You need to take care of object synchronization when concurrency is introduced in the
system.

2 Persistence
 It is property by which object maintains its state across time and space.
 The concept gives rise to the concept of object oriented database.
 It talks about concept of serialization and also about transferring object across
network.

You might also like