33
Best 100+ Frequently Asked Interview Questions in .Net SQL By: Mayank Modi | Folls In: Asp.net, Interview Questions, OOP, SQL Server | Last Updated: Nov 29, 2014 In this tutorial, I’m going to post common and frequently asked technical interview questions in .net sql oops with answers for fresher as well as experience developers. I also wrote many other tutorials on Interview Questions, Asp.net, SQL Server, OOP Concepts as well as Top 10 OOPS Concepts in details. I recommend you to read those tutorials, I’m sure, you’ll enjoy it! It’s very difficult to predict what interviewer will ask during interview, right? . . I think so, but I can assure that following are the best list of possible technical interview questions that I’d faced during my job interviews and also I asked as an interviewer in my professional carrier. Tip: If you are appearing as an experienced developer in the interview, then Why do you want to change the job? is the common question that may be ask before beginning of an interview so prepare first and be clear while answering this question. Interview Questions in .Net: Asp.net, C#, SQL Server, OOPS Concepts Here is the list of best 100+ ever green technical interview questions in .net you must read and prepare for your upcoming interview. 1. In which event Asp.net controls are fully loaded? Ans: Mainly all controls are accessible in Page_Init event except “ViewState” because it doesn’t fully loaded during this event. The Page_Load event guarantees that all the controls are fully loaded and ready to use. 2. How can we identify that the Page is Post Back? Home Asp.net MVC Interview Questions Page 1 of 33 Best 100+ Frequently Asked Interview Questions in .Net SQL 28-04-2016 http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Dotnet FAQ

Embed Size (px)

DESCRIPTION

Dotnet FAQ

Citation preview

Page 1: Dotnet FAQ

Best 100+ Frequently Asked Interview Questions in .Net SQL

By: Mayank Modi | Folls In: Asp.net, Interview Questions, OOP, SQL Server | Last Updated: Nov 29,

2014

In this tutorial, I’m going to post common and frequently asked technical interview questions in .net sql

oops with answers for fresher as well as experience developers. I also wrote many other tutorials on

Interview Questions, Asp.net, SQL Server, OOP Concepts as well as Top 10 OOPS Concepts in details. I

recommend you to read those tutorials, I’m sure, you’ll enjoy it!

It’s very difficult to predict what interviewer will ask during interview, right?

.

.

I think so, but I can assure that following are the best list of possible technical interview questions that I’d

faced during my job interviews and also I asked as an interviewer in my professional carrier.

Tip: If you are appearing as an experienced developer in the interview, then Why do you want

to change the job? is the common question that may be ask before beginning of an interview

so prepare first and be clear while answering this question.

Interview Questions in .Net: Asp.net, C#, SQL Server, OOPS Concepts

Here is the list of best 100+ ever green technical interview questions in .net you must read and prepare for

your upcoming interview.

1. In which event Asp.net controls are fully loaded?

Ans: Mainly all controls are accessible in Page_Init event except “ViewState” because it doesn’t fully loaded

during this event. The Page_Load event guarantees that all the controls are fully loaded and ready to use.

2. How can we identify that the Page is Post Back?

Home Asp.net MVC Interview Questions

Page 1 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 2: Dotnet FAQ

protected void Page_Load(object sender, EventArgs e)

{

if (IsPostBack)

       {

//Page is Post Back

       }

else

       {

//Page is Not Post Back

       }

}

3. What is the difference between ASP and ASP.NET?

Ans: ASP stands for Active Server Pages, also known as Classic ASP which is Microsoft’s server-side technology and used to create dynamic and user-friendly web pages.

Asp.net was developed by Microsoft to allow programmers to build dynamic web sites, web applications or web services. It is an open source server-side web application framework designed for Web development to produce dynamic web pages.

The main difference between ASP and ASP.NET is that ASP is Interpreted Language because ASP uses VBScript; whereas ASP.NET is Compiled Language because ASP.NET uses .NET Languages like C#, Vb.net, which are compiled to MSIL (Microsoft Intermediate Language).

4. What is the lifespan for items stored in ViewState?

Ans: The lifespan of items stored in ViewState lives until the current page expiration including current page

post backs. When user requests another page, the previous page data are no longer available. In short, we

can say that the lifespan for items stored in ViewState exists till your current page exists.

5. Is .NET is Platform Independent? Yes or No?

Ans: It depends on different point of views. There are many of saying that .NET is Platform Independent,

Partially Dependent or Platform Dependent. But in my opinion, .NET is Platform Dependent because it

needs .NET Framework and Windows OS to run your application.

6. Which is the parent class used for the web server control?

Ans: The System.Web.UI.Control class is used for all the web server control.

Home Asp.net MVC Interview Questions

Page 2 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 3: Dotnet FAQ

Ans: The ViewState is a feature that is used by ASP.NET page framework to persist the page and server

control values between round trips or post backs.

The ViewState information is stored in the HTML hidden fields. It is automatically used by the ASP.NET page

framework to persist information that must be preserved between post backs. You can also use ViewStateto store application data that is specific to a page, like this:

//Store the values to ViewState

ViewState["testVS"] = txtID.Text;

//Get the value from ViewStete

if (ViewState["testVS"] != null)

{

     txtID.Text = ViewState["testVS"].ToString();

}

8. What is the use of App_Code folder in Asp.net website?

Ans: When you create website from Visual Studio, the App_Code folder will automatically created in the

website root directory, otherwise you need to add it by right clicking on the project. We can use it to store

the files that we want to use in our website, like common classes, text files, pdf files, email templates,

reports etc.

9. What is the difference between DataSet and DataReader?

Ans: The DataSet has read/write access, we can update records; whereas DataReader has read-only access, we can’t update records.

The DataSet supports both forward and backward scanning of data; whereas DataReader supports forward-

only scanning of data. Read More

10. What is the difference between DataSet and DataTable?

Ans: A DataSet contains a collection of one or more database tables which resides in-memory; whereas A

DataTable contains a single database table which resides in-memory.

A DataSet has a collection of data tables; whereas A DataTable has a collection of rows and columns. Read

More

Tip: I can understand how difficult to be appear in an interview for fresher’s or a little experienced developers? So, my suggestion is to keep calm and do your best with whatever you

Home Asp.net MVC Interview Questions

Page 3 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 4: Dotnet FAQ

impact on interviewer and feels that he/she can perform best during his/her training period or employment.

11. What is AutoPostBack Property?

Ans: If you want to automatically post back page when any event raised, you need to set the AutoPostBackproperty of the asp.net control to True as follows.

<asp:DropDownList ID="ddlCity" runat="server" AutoPostBack="true" />

12. How can you pass the value from one page to another?

Ans: Following are the two common ways to pass the values from one page to another page.

• Session

• QueryString

13. What is SQL Injection? How we can prevent it?

Ans: The SQL Injection Attack is a technique of “insertion” or “injection” of a SQL queries via webpage or web form input controls. SQL injection attacks are a type of injection attack, in which SQL commands are injected into data-plane input in order to effect the execution of predefined SQL commands. It means altering SQL commands into SQL statements, and modifies database tables or data with using SQL Statements like Insert, Update or Delete.

We can prevent SQL Injection Attack by using Parameterized SQL Statements. You can get more details with

step-by-step guide and example by go through the Read More link. Read More

14. What is the difference between String and StringBuilder?

Ans: A String is “immutable”, meaning that once you created string object then you can’t modify it; whereas

A StringBuilder is “mutable”, meaning that once you created string builder object then you can modify or append without creating a new instance for every time.

In String, Any operation that appears to change the string, it creates a new instance of string type in

memory; whereas In StringBuilder, Any operation that appears to modify or append new string, it doesn’t

create a new instance of string type in memory. Read More

15. What is the difference between string and String?

Ans: Technically there is no difference between both of them. In general, string is an alias for System.String.

Home Asp.net MVC Interview Questions

Page 4 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 5: Dotnet FAQ

16. What is DataAdapter? What is the use of DataAdapter?

Ans: The DataAdapter is a part of ADO.NET Data Provider. It provides the communication between the

DataSet and DataSource.

We can use DataAdapter in combination with the DataSet objects for data access and manipulation

capabilities. The DataAdapter uses the SELECT statement to FILL a DataSet or DataTable and other DML

statements like INSERT, UPDATE, and DELETE to make modification to DataSource.

17. Which method of DataAdapter is use to load data to DataSet or DataTable?

Ans: The Fill() method of DataAdapter is use to fill or load the data to DataSet or DataTable, like da.Fill(dt). If you want to check complete example of insert, update, delete including this method, please check here.

18. What is IIS? What is the use of IIS?

Ans: The IIS stands for Internet Information Services which is created by Microsoft to provide Internet based

services to your ASP.NET web applications. It is use to host your web applications on the server. It makes

your local computer to work as a web server which provides functionality to deploy one or more web

applications on the server.

19. What is the difference between ExecuteReader, ExecuteNonQuery and ExecuteScalar?

Ans: The ExecuteReader is generally used to get or read data from result set so it’s appropriate with SELECT Command.

The ExecuteNonQuery is generally used when we want to perform any operation on result set so it’s appropriate with INSERT, UPDATE, and DELETE Command.

The ExecuteScalar is generally used when we need only first value of result set or aggregate functions like

SUM, COUNT, and AVG etc in SELECT Command. Read More

20. ExecuteScalar returns what?

Ans: The ExecuteScalar returns the first column of the first row from the result set returned by the query,

additional rows and columns will be ignore from the result set. It will return null reference if result set is

empty.

21. ExecuteNonQuery returns what?

Ans: The ExecuteNonQuery returns int value as no of row(s) affected. For example, When you are inserting records, you can see “1 row(s) affected”, “5 row(s) affected” etc.

Home Asp.net MVC Interview Questions

Page 5 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 6: Dotnet FAQ

Ans: The User-Defined Function can be used in SQL statements anywhere in the WHERE, HAVING, or SELECT

section; whereas the Stored Procedure cannot be used like this, we can use EXEC statement to execute

stored procedure. Following are some other differences between them:

• Stored Procedure:

– It can be used to Read and Modify data

– It cannot be used to create constraints while creating a table

– It can return 0 or n number of values; and which is OPTIONAL

– It can have “Input” as well as “Output” parameters

– It supports Transaction Management

– It cannot be called from Function

– It can allow SELECT as well as DML statements such as INSERT, UPDATE, or DELETE

– We can use try-catch block to handle exception

• User-Defined Function:

– It can only Read data

– It can be used to create constraints while creating a table

– It can only return 1 value; and which is MENDATORY

– It can only have “Input” parameters

– It does not support Transaction Management

– It can be called from Stored Procedures

– It can only allows SELECT statement under function

– We cannot use try-catch block in a function to handle exception

23. How can you call the connection string from Web.config file?

Ans: You can get and use connection string this way but what if you had specified your connection string in

Web.config and want to get from Web.config file? You can do this by using following single line of code, like

this.

//For C#: Include Namespace – using System.Configuration;

string con = ConfigurationManager.ConnectionStrings["mystring"].ConnectionString;

//For Vb.net: Include Namespace – Imports System.Configuration

Dim con As String = ConfigurationManager.ConnectionStrings("mystring").ConnectionString

24. Define PRIMARY KEY, UNIQUE KEY and FOREIGN KEY?

Home Asp.net MVC Interview Questions

Page 6 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 7: Dotnet FAQ

A UNIQUE KEY constraint enforces the entity integrity and the uniqueness of the values in a set of columns;

so no duplicate values are entered.

On the other hand, FOREIGN KEY constraints are used to enforce referential integrity. A Foreign Key in one table points to a “primary key” or “unique key” on another related database table. It prevent actions that would change rows with foreign key values when there are no primary keys in related table with that same value.

25. What is QueryString? What are the Advantages and Disadvantages of using it?

Ans: The QueryString is use to send the one page information and values to another page on the server. If

you want to check the example, you can see complete querystring example to pass information between

pages here.

• Advantages:

– No external server resources are required so no extra overhead on the server

– Supported by all the browsers without having issue

– We don’t need to put extra efforts in existing code so it is easy to use

• Disadvantages:

– All the attributes and values are visible to the end user, which leads to security threads

– There is a limit to a URL length of 255 characters

26. What are the differences between PRIMARY KEY and UNIQUE KEY?

Ans: A PRIMARY KEY is also a UNIQUE KEY internally, but a primary key cannot allow NULL values; whereas

UNIQUE KEY allows a single NULL value but does not allows multiple NULL values over the columns.

Following are some other differences between them:

• Primary Key:

– A primary key can be only once in a table

– A primary key never allow NULL values

– A primary key is a unique key identifier and cannot be NULL and must be UNIQUE

• Unique Key:

– A unique key can be more than once in one table

– A unique key can allow NULL values but not multiple NULL values

– A unique key can be NULL and may not be UNIQUE

– A unique key cannot be a candidate key

27. What is a NOT NULL Constraint?

Home Asp.net MVC Interview Questions

Page 7 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 8: Dotnet FAQ

Ans: A NOT NULL constraint enforces that the column will not allow or accept NULL values. It is used to

enforce domain integrity.

28. Explain the .NET Architecture.

Ans: The Microsoft .NET architecture is the programming model for the .NET platform. The .NET Framework

provides a managed execution environment, simplified development and deployment and integration with

a wide variety of programming languages.

The .NET Framework has two key parts:

• Framework Class Library (FCL): The .NET Framework Class Library is a comprehensive,

object-oriented collection of reusable types that you can use to develop applications.

The .NET Framework class library includes ADO.NET, ASP.NET, and Windows Forms. It has a

collection of 7000+ classes and data type that enable .NET applications to access databases,

read & write files, processing XML, GUI, drawing, web services and many more. Some of the

examples are System.Data, System.Web, System.SqlClient etc.

• Common Language Runtime (CLR): The CLR is the execution engine for .NET applications

& servers as the interface between .NET applications and the operating system. Following are

the key features of the CLR:

– Loads & execute code, which includes conversion of intermediate language to native

machine code

– Separates process and memory

– Memory and Objects Management

29. Explain ASP.NET Page Life Cycle.

Ans: When a page is requested, it is loaded into the server memory, processed and sent to the browser.

Then it is unloaded from the memory. At each of this steps, methods and events are available, which could

be overridden according to the need of the application. In other words, you can write your own code to

override the default code.

When we execute an ASP.NET Webpage, it passes through the following stages which we can call “Page Life Cycle”:

• Page Request: When the page is requested by a user, ASP.NET determines whether the page

needs to be parsed and compiled or whether a cached version of the page can be sent in

response without running the page. The page request done before the page life cycle starts.

Home Asp.net MVC Interview Questions

Page 8 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 9: Dotnet FAQ

• Start: In this stage, the Request and Response objects are set. If the request is an old request

or post back, the IsPostBack property of the page is set to true. The UICulture property of the

page is also set.

• Initialization: In this stage, the page initialize and the control’s UniqueID property are set.

• Load: In this stage, if the current request is a post back, control properties are loaded with

information recovered from view state and control state.

• Validation: In this stage, if all server controls on the webpage validates and runs successfully,

the IsValid property of the page is set to “true” (which let you to post data on the server) else

set to “false” (which prevent you to post data on the server).

• Postback Event Handling: In this stage, if the request is a post back, the related event

handler is called.

• Rendering: Before rendering, ViewState is saved for the page and all controls. During the

rendering stage, the page calls the “Render” method for each control, providing a text writer

that writes its output to the OutputStream object of the page’s Response property.

• Unload: In this stage, the rendered page is sent to the client and page properties, such as

Response and Request are unloaded and all cleanup done.

30. Explain ASP.NET Page Life Cycle Events.

Ans: At each stage of the page life cycle, the page raises some events, which could be coded. An event

handler is basically a function or subroutine, bound to the event, using declarative attributes like Onclick or

handle.

Following are the page life cycle events:

• PreInit: The PreInit is the first event in page life cycle. It checks the IsPostBack property and

determines whether the page is a postback. It sets the themes and master pages, creates

dynamic controls and gets and sets profile property values. This event can be handled by

overloading the OnPreInit method or creating a Page_PreInit handler.

• Init: The Init event fires when the page is initializing.

• InitComplete: The InitComplete event fires when all the controls turn on view state tracking.

• LoadViewState: The LoadViewState event fires when the view state is loading.

• LoadPostData: The LoadPostData event fires when the post back data is processing.

• PreLoad: The PreLoad event fires after the page loads view state for itself and all controls,

and after it processes post back data that is included with the Request instance.

Home Asp.net MVC Interview Questions

Page 9 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 10: Dotnet FAQ

• Control events: Use these events to handle specific control events, such as a Button

control’s Click event or a TextBox control’s TextChanged event.

• LoadComplete: The LoadComplete event fires at the end of the event-handling stage. When

the loading process is completed, control event handlers are run and page validation takes

place. This event can be handled by overloading the OnLoadComplete method or creating a

Page_LoadComplete handler.

• PreRender: The PreRender event fire just before the output is rendered. By handling this

event, pages and controls can perform any updates before the output is rendered.

• PreRenderComplete: The PreRenderComplete event fires just after each data bound control

whose DataSourceID property is set calls its DataBind method.

• SaveStateComplete: The SaveStateComplete event fires after view state and control state

have been saved for the page and for all controls. Any changes to the page or controls at this

point affect rendering, but the changes will not be retrieved on the next post back.

• Render: Actually Render is not an event; but at this stage, the Page object calls this method

on each control. All the server controls have a Render method that writes out the control’s

markup to send to the browser.

• Unload: The Unload event fires when the page is destroying the instances of the server

controls.

31. What is the difference between C and C++?

Ans: C is a Procedural-Paradigm Language; whereas C++ is a Multi-Paradigm Language, which means

procedural, functional as well as object oriented programming language.

Mapping between Data and Function is difficult and complicated in C; whereas In C++, Mapping between

Data and Function can be done using “Objects”. Read More

32. What is a DEFAULT Constraint?

Ans: A DEFAULT constraint is used to add values into a column when values were omitted. It will take the default value (which we can specify during table creation) and insert into that field when no value is inserted for that field. The DEFAULT values can be in form of “integer”, “bool” or “datetime” fields but cannot be defined on TIMESTAMP and IDENTITY columns.

33. What is Object?

Ans: An Object is a real-world entity that keeps together property states and behaviors. To see an example,

Read More from here.

Home Asp.net MVC Interview Questions

Page 10 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 11: Dotnet FAQ

Ans: A Class is a collection of objects and represents description of objects that share same attributes and

actions. It contains characteristics of the objects such as objects attributes, actions or behaviors. To see an

example, Read More from here.

35. What is Method?

Ans: A Method is an object’s behavior. To see an example, Read More from here.

36. What is the difference between DELETE and TRUNCATE?

Ans: A DELETE command removes the rows from a table on the basis of the condition that we provide

within WHERE clause; whereas a TRUNCATE command will remove all of the rows from a table. A DELETEcommand is a DML statement; whereas a TRUNCATE command is a DDL statement.

TRUNCATE command “Resets the IDENTITY Field” of the table while removing all the rows from the table but the table columns, constraints, indexes, permissions, and structures remains as it is.

In DELETE command we can do rollback; whereas In TRUNCATE command we cannot do rollback.

Note: You cannot use TRUNCATE statement on a table which is referenced by a FOREIGN KEY constraint. If

you want to retain the IDENTITY Field counter, then you can use DELETE command. If you want to remove

table definition, data, and its structure, you can use DROP command.

37. What is actually returned from server to the browser when a browser requests as .aspx file and

the file is displayed?

Ans: When a browser requests .aspx file, then the server returns a response which is rendered into a HTML string. Actually at that time all of the server controls are converted into HTML control format because web browsers doesn’t understand the server controls; they only understand HTML strings to display results.

38. What is Encapsulation?

Ans: An Encapsulation is the process of keeping or enclosing one or more items within a single physical or

logical package. In object oriented programming methodology it prevents access to implementation

details. To see an example, Read More from here.

39. Which two new properties are added in ASP.NET 4.0 Onwards in Page Class?

Ans: The MetaDescription and MetaKeyword are the two properties introduced in Page Class in ASP.NET 4.0

Onwards. To see an example, Read More from here.

40. What is the difference between Authentication and Authorization?

Home Asp.net MVC Interview Questions

Page 11 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 12: Dotnet FAQ

41. What is Abstraction?

Ans: An Abstraction is the process of providing only essential information to the outside real world and

hiding overall background details to present an object. It relies on the separation of interface and

implementation. To see an example, Read More from here.

42. What is Information Hiding?

Ans: An Information Hiding concept restricts direct exposure of the data. Data is accessed indirectly using

safe mechanism, methods in case of programming object. Follow the example given in Abstraction.

43. What is Inheritance?

Ans: An Inheritance in OOP allows us to create a new class using an existing one meaning extending one

class to another. The main advantage of extending classes is that it provides a convenient way to reuse

existing fully tested code in different context thereby saving lots of time with existing coding and its model

style. To see an example, Read More from here.

44. What are Custom User Controls? How can you register it to a webpage?

Ans: The Custom User Controls are the controls that are defined by developers. These controls are a mixture

of custom behavior and predefined behavior. These controls works similar to other web server controls.

The @Register directive is used to register a custom server control to a webpage.

//Register control using following statement right after @ Page directive

<%@ Register TagPrefix="myASP" TagName="myControl" Namespace="MyApp.Controls"

Assembly="MyApp" %>

//You can use like this in your .aspx page..

<myASP:myControl runat="server"/>

45. What are the difference between Abstract Class and Interface?

Ans: Following are the difference between both of them:

• Abstract Class:

– Abstract class does not support multiple inheritance

– Abstract class contains Data Member

– Abstract class contains Constructors

– An abstract class Contains both incomplete (abstract) and complete member

– An abstract class can contain access modifiers for the subs, functions, properties

Home Asp.net MVC Interview Questions

Page 12 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 13: Dotnet FAQ

• Interface:

– Interface can support multiple inheritance

– Interface doesn’t contains Data Member

– Interface doesn’t contains Constructors

– An interface contains only incomplete member (signature of member)

– An interface cannot have access modifiers by default everything is assumed as public

– Member of interface cannot be Static

46. What is Polymorphism?

Ans: The word Polymorphism means having many forms. Generally, polymorphism occurs when there is a

hierarchy of classes and they are related by inheritance. To see an example, Read More from here.

47. What is Method Overloading?

Ans: It allows multiple functions to exist with same name with different signature or parameters. For

example, if you take a “bike” as an example, it has a function “start” with two forms that is “Cell Start” or

“kick Start”. To see an example, Read More from here.

48. What is Method Overriding?

Ans: It means changing the behavior of the methods of a base class in derived class by overriding the base

class methods. For example, if “Base” is a base class with “Calculate” method and class “Derive” inherits

class “Base”, thus derives method “Calculate” of class “Base”. The behavior of “Calculate” in class “Derive”

can be changed by overriding it. To see an example, Read More from here.

49. How can you send an email message from an ASP.NET Webpage?

Ans: The MailMessage and SmtpMail classes of System.Net.Mail are used to send an email from your

ASP.NET webpage. You also need to create an object of the SmtpClient class to set the server name, port,

and credentials. To see an example, Read More from here.

50. Explain Validation Controls.

Ans: Validation controls are responsible to validate the data of an input controls. When we use validation

control to any specific web server control, it performs the validation on client-side (also if you want to do

server-side validation using these validation control) and displays an error message to user with

appropriate message to correct the filled details, in case of the validation fails. Following are the available

validation server controls to validate web form.

• RequiredFieldValidator: This checks if control contains data or not.

Home Asp.net MVC Interview Questions

Page 13 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 14: Dotnet FAQ

• CustomValidator: This checks the data entered using a client-side script or a server-side

code.

• CompareValidator: This validation control ensure that the values in two different web server

controls are matched or not.

• RangeValidator: This checks if entered data is according to the range of two values that is

specified in MinimumValue and MaximumValue property of this validation control.

• RangeValidator: This allows user to display the summary of errors at one place in detail.

51. Which method is used to force all the validation controls to run?

Ans: The Page.Validate() method is used to force all the validation server controls to run and to perform

validation.

52. How many Web.config files can we add in single project?

Ans: There might be more than one Web.config files for a single project depending on the hierarchy levels of

the project folders so we can add mostly one Web.config file for each folder hierarchy level.

53. What is Boxing and Unboxing concepts in .NET?

Ans: A Boxing is a process of converting the value type into reference type; whereas an Unboxing is a reverse

process of it means converting reference type to value type.

// int (value type) is created on the "Stack"

int stackVar = 12;

// Boxing = int is created on the "Heap" (means reference type)

object boxedVar = stackVar;

// Unboxing = boxed int is unboxed from the heap and assigned to an int stack variable

int unBoxed = (int)boxedVar;

54. What are the difference between value type and reference type?

Ans: A Value Type stores its contents in memory allocated on the stack. When you created a “value type”, a

single space in memory is allocated to store the value and that variable directly holds a value; whereas a

Reference Types are used by a reference which holds a reference or address to the object but not the object itself because reference types represents the address of the variable rather than the data itself, assigning a reference variable to another doesn’t copy the data.

Examples of reference types are Classes, Objects, Arrays, Indexers, and Interfaces etc; on the other hand,

Home Asp.net MVC Interview Questions

Page 14 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 15: Dotnet FAQ

//Here the value 5 is stored in an area of memory called the "Stack"

int intStack = 5;

//Here the space required for the 5 strings array which is allocated on the "Heap"

string[] arrHeap = new string[5];

55. What is the difference between GridView and DataGrid?

Ans: The GridView is a web control; whereas the DataGrid is a windows control.

• GridView:

– In GridView control, you can add paging, sorting, or editing capabilities with enabling simple

gridview’s property

– GridView has “EditTemplates” template to enable inline editing

• DataGrid:

– In DataGrid control, we need to add events for paging, sorting, or editing capabilities

– DataGrid does not have “EditTemplates” template to enable inline editing

56. What is a Partial Class?

Ans: When web application is too complex, then there is possibility that multiple developers can work on same modules to speed up development process. So in this situation instead of defining an entire class at once if becomes more difficult to implement as well as understand, so we can split or divide the definition into multiple classes by using “partial” keyword.

At compile or runtime, a compiler will group all the partial classes together and treat them as a single class. There are a several advantages to use partial classes, such as developers can work on different parts of the classes from different places without needing to share same physical files. Following is the simple example to understand the concept of partial class:

public partial class student

{

public void GetStudentDetails()

     {

//developer is working on student details module

     }

//some other function for same modules..

}

Home Asp.net MVC Interview Questions

Page 15 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 16: Dotnet FAQ

public void GetStudentResults()

     {

//developer is working on student results module

     }

//some other function for same modules..

}

57. What is Cookie? What is the default timeout for a Cookie?

Ans: The Cookie is a small text file on the client machine either in the client’s file system or memory of the client browser session. Cookies are not good for sensitive data. Moreover, Cookies can be disabled on the browser so we can’t rely on cookies for the state management.

In other words, Cookie is a lightweight executable program which the server posts to client’s machines.

That includes the identity of the user at the first visit of the specific website and on second visit cookie is

used to validate the user for their authenticity. This is not the only use of Cookie but there are several

others. The Cookie.Discard property is set to “true” means Cookie is turn off for a webpage so it instructs the client application not to save the Cookie on the user’s machine.

The values of a Cookie can be transferred between the user’s request and the server’s response. The default timeout for the Cookie is 30 minutes.

58. What is Session? What is the default timeout for a Session?

Ans: The Session object stores information about, or change settings for a user session. It is used for State

Management in ASP.NET. A Session starts when the browser first request a resources from within the

application; and ends when either browser closed or session timeout has been expired.

The default timeout for the Session is 20 minutes but you can change it from Web.config file or override

session timeout from IIS settings.

59. Can you change Session default timeout? If yes, How?

Ans: Yes, we can change the default session timeout from Web.config file. The session timeout is specified in

the Web.config file within sessionstate element. You can change the session timeout setting by changing the

value of timeout attribute of sessionstate element in Web.config file, like this:

<configuration>

<system.web>

<sessionState timeout="50"/>

Home Asp.net MVC Interview Questions

Page 16 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 17: Dotnet FAQ

60. What is the use of Web.config file?

Ans: The Web.config file contains configuration setting for a web application or project, such as Database

Connections, Error Page Settings, Session States, Error Handling, HttpHandlers, Security like Authorization

and Authentication, Culture Specific Settings etc.

61. What is the use of Global.asax file?

Ans: The Global.asax file is used to execute the application-level events and sets the application-level

variables. It contains application-level events, such as Application_Error, Application_Start,

Application_End, Session_Start, Session_End etc. You can also add custom event that is supported by

Global.asax file.

62. What is the difference between Normalization and De-normalization?

Ans: In the relational database design, the process of organizing data to minimize redundancy is called

“Normalization”. It usually involves dividing data into different tables and defining relationships between

the tables. The key feature of the Normalization is to eliminate the data redundancy and ensure the data

dependency.

On the other hand, the process of attempting to optimize the performance of a database by adding redundant data is called “De-normalization”. It is sometimes necessary because current database management systems implement the relational model poorly. The key feature of the De-normalization is to move from

higher to lower normal forms of database modeling in order to speed up database access.

63. What is a Stored Procedure? Explain its advantages.

Ans: A Stored Procedure is a set of SQL statements that have been previously created and stored into the

SQL server database to perform some operation, such as retrieving result set from tables, insert, update,

delete data etc. You can also use it to backup a database or perform other maintenance tasks on regular

intervals.

It can accept input parameters so that a single stored procedure can be used several times over that network by several clients using different input data.

• Advantages:

– It can reduce network traffic; results in improved performance of website

– It provides a public interface to a database

– Group of all queries at the same location, making it easier for DBAs to see how the database

is queried and optimize it accordingly.

– Reusability

Home Asp.net MVC Interview Questions

Page 17 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 18: Dotnet FAQ

– Because scripts are in one location, updates and tracking of dependencies based on

schema changes becomes easier

• Advantages:

– Limited Coding Functionality

– Any data errors in handling Stored Procedures are not generated until runtime

– It is very difficult to debug Stored Procedure

– It is not efficient to use when we deal with complex logic

– If more than one application are using the same database server very frequently, it can

increase the load on server so that application becomes slow.

Note: In my opinion, We can use stored procedures to encapsulate complex queries, such as complex joins, and complex conditions with “WHERE” clause etc but don’t use Stored Procedures for complex application or website logic even don’t try Stored Procedures for CRUD operations with complex logic. So, Stored Procedures should be used in a minority of cases rather than be the standard tool for all queries in an application or website.

64. What is a Trigger? Explain Types of Trigger.

Ans: A Trigger is a special type of SQL procedure that initiates an action when an event like INSERT,

UPDATE, or DELETE occurs on an database table objects. A trigger cannot be called or executed directly;

DBMS automatically fires the trigger as a result of a data modification to the associated table or in the case

of DDL triggers to a DDL event in the database. There are 2 types of triggers:

1) DML Trigger – It can be form of Instead of Trigger and After Trigger. The Instead of Triggers are fired in

place of the triggering action such as an INSERT, UPDATE, and DELETE; whereas the After Triggers execute

after the triggering action such as an INSERT, UPDATE, and DELETE.

2) DDL Trigger – The DDL Trigger are fired against DDL statements like DROP, CREATE, and ALTER table.

These types of triggers are always After Triggers.

65. What is the difference between Triggers and Stored Procedures?

Ans: Triggers are similar to the stored procedures in that both consist of procedural logic that is stored at

the database level to perform some action with database objects. The Stored Procedures are “explicitly

executed” by invoking a call to the procedure; whereas the Triggers are “implicitly executed” by any events. In addition, triggers can also execute stored procedures.

66. What is a view?

Ans: A view can be used to retrieve data as well as update or delete rows. It can be thought of a stored query

Home Asp.net MVC Interview Questions

Page 18 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 19: Dotnet FAQ

– It provides a security mechanism which restricts users to a certain subset of data– It provides a feature for developers to customize how users can logically view the data

67. What is the difference between the Response.Write() and Response.Output.Write()?

Ans: The Response.Write() is used to write the normal output; whereas the Response.Output.Write() is used

to write the formatted output.

68. What does the Orientation property do in a Menu Control?

Ans: The Orientation property of the Menu Control sets the menu display layout on the webpage, either

“horizontal” or “vertical” display. To see an example, Read More from here.

69. Difference between the Client-side and Server-side Validation?

Ans: The Client-side validations take place at the client-end with the help of JavaScript or jQuery; whereas

the Server-side validations take place at the server-end with the help of user-defined conditions.

70. Which method is used to redirect a webpage?

Ans: The Response.Redirect method is used to redirect a webpage, like following example.

Response.Redirect("Default2.aspx");

71. What is State Management? Explain types of State Management.

Ans: The State Management is used to store the information of all the web server and user requests. It also

used to trace the information or data that affect the state of the applications. Following are the two ways to

maintain a state in ASP.NET website.

• Client-Based State Management: This type of state management maintains the

information on the client’s machine using following objects.

– Cookies

– ViewState

– ControlState

– HiddenFields

– QueryString

• Server-Based State Management: This type of state management maintains the

information on the server using following objects.

– ApplicationState

– SessionState

Home Asp.net MVC Interview Questions

Page 19 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 20: Dotnet FAQ

72. How does a Content-page is differ from a Master-page?

Ans: The Content-page is a child page that can be inherited by a Master-page. The Content-page does not

have complete HTML source code; whereas the Master-page has complete HTML source code inside its

source file. In short, we can say that master page contains full html markup code that is used to display data

to the users on the web browser.

73. Explain Login Controls?

Ans: The Login Controls use the Membership system to authenticate a user credentials for a web

application. The Login Controls are built-in controls in ASP.NET for providing login functionalities to website

or web application. Following are the common controls available that are available within a login control.

• Login Control: It provides a gui interface for user authentication. It consists of a set of

controls, such as TextBox, Label, Buttons etc.

• ChangePassword Control: It provides a gui interface and functionalities to change user

password.

• LoginView Control: It provides appropriate information to different users according to the

user’s status.

• LoginStatus Control: It shows a login link to users, who are not authenticated and logout

link, who are authenticated.

• CreateUserWizard Control: It provides a gui interface to the user to register for the website

or web application.

• LoginRecovery Control: It allows users to get back password through an email, if they

forget.

• LoginName Control: It displays a user name, if the user logged in.

74. What is the PlaceHolder Control? Can we see it at runtime?

Ans: The PlaceHolder Control acts as a container for those controls that are dynamically generated at runtime. We cannot see it at runtime because it does not produce any visible output. It only used as a “Container” of other web server controls.

75. What are the templates can be used within Repeater Control?

Ans: The Repeater control contains the templates, such as HeaderTemplate, ItemTemplate,

SeparatorTemplate, AlternatingItemTemplate, FooterTemplate etc. To see an example, Read More from

here.

Home Asp.net MVC Interview Questions

Page 20 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 21: Dotnet FAQ

Ans: The @Page directive is responsible to assign page specific attributes for the page parser and the

compiler in an ASP.NET Application. Following is the simple example of @Page directive; which is the first

line of your .aspx web page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"

Inherits="Default" %>

77. What are the major built-in objects in ASP.NET?

Ans: Following are all the common built-in objects in ASP.NET that we can use frequently during website

development.

• Request

• Response

• Data

• Application

• Server

• Context

• Session etc

78. What is an index?

Ans: An index is a physical structure that contains pointers that point to a physical location of the data. It is

possible to create an index on one or more columns of a table, and each index is given a name.

An index is an ordered list of the contents of a columns or a group of columns of a table, in that “ROWID” indicates exactly where the record is stored in the table.

The users can see the index name but cannot see the indices themselves; they are just used to speed up queries. An Index can give you improves query performance because a “seek action” (it means you can able to locate records without having to examine every row to locate those records) occurs for retrieving records from your table in a query. There are several key features of creating an index, few of them are:

– Indices are created in an existing table to locate rows more quickly and efficiently– It is used to speed up queries

– It is used to improve query performance of a database application

79. What is a cursor?

Ans: A is a database object used by applications in the procedural logic to manipulate data in a row-

Home Asp.net MVC Interview Questions

Page 21 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 22: Dotnet FAQ

– Declare a cursor– Open a cursor

– Fetch a row from the cursor

– Perform your task on fetched row

– Close a cursor

– Deallocate the cursor

80. Why do we need nested Master Pages in an ASP.NET Website?

Ans: It is appropriate to use nested Master Pages in an ASP.NET Website when we deal with several hierarchical levels in a Website. For an example, if we are creating “School Management System” so there should be several hierarchies of departments such as Student, Teacher, and Admin etc; In this case we can use nested master pages.

81. What is the appSettings section in Web.config file?

Ans: Usually the Web.config file contains configuration settings for a web application. The appSettingssection contains set of user-defined values for the whole web application. Following is the simple example that specifies the “ConnectionString” and “Email” that we can use later throughout the project.

<configuration>

<appSettings>

<add key="ConnectionString" value="myConnectionString here.." />

<add key="Email" value="[email protected]"/>

</appSettings>

</configuration>

82. Web form belongs to which class from .NET Framework Class Library?

Ans: A Web form belongs to the System.Web.UI.Page Class from .NET Framework Class Library.

83. Which Data Type does the RangeValidator Control support?

Ans: Integer, String, Currency, Double, and Date.

84. What does the EnableViewState property do? Why do we want it to On or Off?

Ans: The EnableViewState property enables the “ViewState” property on the page. When the

EnableViewState property is set to false (means Off), the page does not store the users input during post

back requests of the webpage. On other hand, when this property is set to true (means On), the page saves

the users input between post back requests of the webpage. Following is the simple example that states

that the EnableViewState property is set to “Off”.

Home Asp.net MVC Interview Questions

Page 22 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 23: Dotnet FAQ

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"

Inherits="Default" EnableViewState="true" %>

85. Why a SiteMapPath Control is referred to as a breadcrumb or eyebrow navigation control?

Ans: The SiteMapPath Control helps to display all the web pages into hierarchical path including the root

which helps users to navigate the web pages of the website. Therefore, it is known as the breadcrumb or

eyebrow navigation control. To see an example, Read More from here.

86. What are the different types of SQL JOIN?

Ans: Sometimes it becomes necessary to work with multiple tables as though they were a single entity or

object. When we want to show result set from one or more related tables at one place, JOINS are comes into

the picture. Following are the types of SQL JOINS that we can use in our day to day development:

• 1. INNER JOIN: It also known as “Equi Join” because the WHERE statement generally

compares two columns from two tables with the “= (that is a equivalence operator)”, most

commonly used type, many database systems use this as by default join. INNER JOIN returns

all the rows from both the tables where there is a match. In short, we can say that use it when

you are want to select only those rows that have values in common in the columns specified

in the “ON” clause, which is required. Following is the simple example of INNER JOIN which

perform join ON “studid” which can be match rows and common between both the tables: Example:SELECT s.studid, s.studname, r.marks FROM Student s INNER JOIN Result r

ON r.studid = s.studid;

• 2. LEFT JOIN: It returns all the rows from the LEFT table, even if there is no match in the

RIGHT table. Following is the simple example statement of LEFT JOIN: Example:SELECT s.studid, s.studname, r.marks FROM Student s LEFT JOIN Result r

ON r.studid = s.studid;

Note: It’ll return all the rows from the left table (Student), even if there is no match in the right table (Result).

• 3. RIGHT JOIN: It returns all the rows from the RIGHT table, even if there is no match in the

LEFT table. Following is the simple example statement of RIGHT JOIN: Example:

Home Asp.net MVC Interview Questions

Page 23 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 24: Dotnet FAQ

SELECT s.studid, s.studname FROM Student s RIGHT JOIN Result r

ON r.studid = s.studid;

Note: It’ll return all the rows from the right table (Result), even if there is no match in the left table (Student).

• 4. CROSS JOIN: It returns all the possible combinations of the result set from the listed

tables. This kind of join is usually not preferred as it may take a long time to retrieve data and

produce huge result set which may decrease the performance of the application. Example:SELECT * FROM Student CROSS JOIN Department;

Note: It’ll return all the row combination between both the tables. If Student table have “3” records

and Department table have “5” records, then it’ll produce total of “15” records, however it doesn’t matter about a row match.

• 5. SELF JOIN: A SELF JOIN is a join of a table with itself. A common use of this join is when

the table stores entities or records which have a hierarchical relationship between them. For

example, if you want to show name of the employee and corresponding manager as a pair,

student and corresponding faculty as a pair etc. Example:SELECT s1.studname, s2.factname FROM Student s1 INNER JOIN Student s2

ON s1.studid = s2.factid;

Note: It’ll return the names of student and corresponding faculty as a pair.

87. What is the difference between Web Server and HTML Controls?

Ans: The Web Server controls are server-side controls so all the validations are performed at the server-side;

whereas the HTML controls are client-side controls so all the validations are performed at the client-side.

Web browser does not understand server controls so after page processing all the server controls are

converted into html controls to display results on the browser.

88. What is the Code-behind feature in ASP.NET?

Ans: The Code-behind feature of ASP.NET enables you to divide an ASP.NET page into two files – one consisting of the presentation data (which contains the user interface elements, such as HTML and Web Server Controls), and the second one consisting of the business logic (which contains the event-handling process to handle the events that are fired by the controls). It also allows us to debug and trace the code.

Home Asp.net MVC Interview Questions

Page 24 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 25: Dotnet FAQ

The file that contains the presentation data has the “.aspx” extension, for example myFile.aspx; whereas the file contains the business logic has the “.cs” or “.vb” extension depending upon the type of selected programming language that is C# or VB respectively, for example “myFile.aspx.cs” or “myFile.aspx.vb”.

89. What is the difference between ASP.NET Label and Literal Control?

Ans: The Label control represents HTML tag; whereas the Literal control represents plain text (when it

converted, rendered and becomes ready to show data on the web browser) which is not surrounded by any

HTML tag.

90. How many types of Cookies are available in ASP.NET?

Ans: There are two types of Cookies available in ASP.NET.

• Session Cookie: This type of Cookie resides on the client machine for a single session until

the user does not Logout.

• Persistent Cookie: This type of Cookie resides on a user’s machine for a period specified for

it to expire, such as 1 day, 7 day, 1 month etc.

91. Which method do you use to kill explicitly a users session?

Ans: The Session.Abandon() method kills the user session explicitly. You can also use Session.Remove(“mySession”) method to remove any specific one session OR Session.RemoveAll() method to remove all

the sessions.

92. List 3 or 4 common properties of all validation controls?

Ans: Following are the common properties that can be use for any validation control.

• ControlToValidate

• Text

• ErrorMessage

• ForeColor

93. What is CrossPagePostBack in ASP.NET?

Ans: The CrossPagePostBack is used to access previous page controls to next page using PostBackUrlproperty of web server control in Asp.net. To see an example, Read More from here.

94. Can we validate a DropDownList by using RequiredFieldValidator?

Home Asp.net MVC Interview Questions

Page 25 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 26: Dotnet FAQ

<asp:DropDownList ID="myDropDown" runat="server">

<asp:ListItem Text="Please select" Value="0" Selected="True"></asp:ListItem>

<asp:ListItem Text="Asp.net" Value="1"></asp:ListItem>

<asp:ListItem Text="C#" Value="2"></asp:ListItem>

</asp:DropDownList>

<asp:RequiredFieldValidator ID="rfvmyDropDown" runat="server" ControlToValidate="myDropDown"

ErrorMessage="*" InitialValue="0" />

95. What are the Web Form Events available in ASP.NET?

Ans: Following are the common ASP.NET Web form events available:

• Page_Init

• Page_Load

• Page_PreRender

• Page_Unload

• Page_Disposed

• Page_Error etc.

96. Define Namespace.

Ans: The Namespaces are the way to organize programming code. It eliminates the chances of name

conflicts or duplication. For example, myProject.Default1, myproject.Webform1, where myProject is a

namespace and Default1, and Webform1 are the class respectively.

You can use namespaces outside your project by referring them using “References” dialog box by right clicking on project and include in code file using “Imports” in .vb and “using” in .cs statement to access members of the namespaces in code. Most likely we can use it when we use “3-tire” or “n-tire” architecture with business logic (BAL), data access logic (DAL) and so on.

97. What is the use of static keyword in .NET?

Ans: A static variable is a same as constant variable but we can change the value of static variable and we

can access the variables without creating class objects or instances.

98. In which case we need to use Abstract Class or Interface?

Ans: We can implement Interface when we want that the “derived” class must implement all the methods of

a “base” class; whereas on the other hand we can use Abstract Class when we want only some method of “base” class in our “derived” class.

Home Asp.net MVC Interview Questions

Page 26 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 27: Dotnet FAQ

Ans: The System Exception is thrown by “Common Language Runtime” (CLR); whereas the System Exception is thrown by same “Application” or “Website”.

100. Explain the difference between a class and a structure.

Ans: Following are the some common differences between a class and a structure:

• class:

– It is a reference type

– It can have destructor

– All variables in classes are by default private– Good to be used from architecture view as it provides high flexibility

– Null value can be assigned to a variable in a class

• structure:

– It is a value type

– It cannot have destructor

– All variables in structure are public– Good to be used for simple data structures

– Null value assignment is not feasible in a structure

101. Explain the difference between Response.Redirect and Server.Transfer.

Ans: Following are the some common differences between a Response.Redirect and a Server.Transfer:

• Response.Redirect:

– It is used to redirect a user to another webpage or website permanently

– It causes additional roundtrips to the server on each request

– It is used to navigate within the same website as well as from one website to another

website

– Since it has round-trips, it provides less response as compared to Response.Transfermethod

• Server.Transfer:

– It is used only to transfer .aspx pages but not website

– It preserves server resources and avoids the unnecessary roundtrips to the server

– It is only used to navigate within the same website and not outside website

– Since it has no round-trips, it provides faster response and does not update the client’s

Home Asp.net MVC Interview Questions

Page 27 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 28: Dotnet FAQ

Note: The round-trip is a process of a webpage from client to the server and then back from server to the

client, including client request to server response.

102. What is the difference between HAVING and WHERE Clause?

Ans: A HAVING clause used to specify a search condition for a “GROUP BY” or an Aggregate functions, such

as AVG, SUM etc; whereas a WHERE clause is applied to filter out each rows from the table.

The main difference between both of them is that a HAVING clause can be used only with the SELECT

statement; whereas a WHERE clause can also be used with DELETE and UPDATE commands.

103. What is Table-Valued Parameters in SQL?

Ans: A Table-Valued Parameters (TVP) is introduced in SQL Server 2008. The Table-Valued Parameters are

declared using “User-Defined Table Type”; it is used to send multiple rows of data to a stored procedure or

a function without creating a temporary table or passing in multiple parameters. To see an example, Read

More from here.

104. What are Constructors and Destructors?

Ans: A Constructors are special methods, used when instantiating a class. It can never return anything,

which is why you don’t have to define a return type for it. To see an example, Read More from here.

Destructors method called once an object is disposed, and can be used to cleanup resources used by the

object. Destructors don’t look very much like other methods. To see an example, Read More from here.

105. Which ASP.NET objects encapsulate the state of the client and the browser?

Ans: The Session object encapsulates the state of the client and the web browser.

Join more than 2500 others

My posts. Your inbox. Sounds good!

11 Shares5

Share2

Share1

Pin Tweet Share

Home Asp.net MVC Interview Questions

Page 28 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 29: Dotnet FAQ

E-Mail Address

Subscribe

About Mayank ModiMayank is a web developer and designer who specializes in back-end as well as front-end

development. He's a Founder & Chief Editor of AspnetO. If you'd like to connect with him,

follow him on Twitter as @immayankmodi.

Comments

Kumar says

Dec 24, 2015 at 3:17 PM

Nice article. It’s helpful for Fresher to 2+ exp..

Reply

Mukesh Shukla says

Sep 12, 2015 at 1:06 AM

a lot of thanks modi sir plz update complete information about page life cycle in asp.net with example

Reply

Home Asp.net MVC Interview Questions

Page 29 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 30: Dotnet FAQ

Name * Email *

Manas Acharya says

Jul 24, 2015 at 11:53 PM

I never seen this type of article before

Reply

Krutal Modi says

Jan 21, 2015 at 12:32 PM

Nice article. It helped me lot !!! Keep it on…

Reply

Share Your Comments & Feedback

Website

Comment

Home Asp.net MVC Interview Questions

Page 30 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 31: Dotnet FAQ

Submit Comment

Search

Join 2500+ Programmers

f1,624

Fans

T4,610Followers

+21

Followers

48

Followers

1,080

Subscribers

Home Asp.net MVC Interview Questions

Page 31 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 32: Dotnet FAQ

Find by Tags

Ado.net Ajax appSettings Asp.net C#CheckBox CheckBoxList ConnectionStrings

Control CSS CSS3 Difference Download

DropDownList Export Facebook fadeIn fadeOut

fadeTo fadeToggle File File Extension FileUpload Function

GridView IIS Interview Questions

JavaScript jQuery MVC OOP

RadioButtonList RDP Repeater Send Mail

Solutions Split SQL Stored Procedure TextBox

Upload Validation VB Web.config Web HostingThe Man Behind AspnetO

Hi there,

Myself Mayank Modi, a Software Engineer and a blogger from Surat, India.

I'm welcoming you to my blog - AspnetO, a programmers community blog where we code, that works!

I started AspnetO as a hobby and now we're growing day by day. We're now having 2500+ programmers

Subscribe To Newsletter

Enter your email address to subscribe to this blog and receive notifications of new posts right to your inbox

Join 1000+ other subscribers

E-Mail Address Subscribe

Alexa Traffic Rank

Home Asp.net MVC Interview Questions

Page 32 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...

Page 33: Dotnet FAQ

Here at AspnetO, I write about Beginners to Advance level of tutorials on programming languages like Asp.net using C# and Vb.net, MVC, SQL Server, JavaScript, jQuery etc. In sort, all about Asp.net website development stuff and sometimes sharing tips and tricks that can help you to grow up your programming skills.

You can get more details about me and my blog at About us page.

Hot on AspnetO

Gridview Insert Update Delete Example in Asp.net, C#,

Vb.net 7045 downloads 39.76 KB

Download This Example

Gridview Insert Update Delete Example in Asp.net, C#,

Vb.net 6324 downloads 39.76 KB

Download This Example

Gridview Insert Update Delete Example in Asp.net, C#,

Vb.net 6319 downloads 39.76 KB

Download This Example

Export gridview all rows or selected rows to word,

excel, text, pdf examples 3121 downloads 1.01 MB

Download This Example

Export gridview all rows or selected rows to word,

excel, text, pdf examples 3105 downloads 1.01 MB

Download This Example

Copyright © 2014 - 2016 · All Rights Reserved.

About | Copyrights | Privacy | Terms | Contact | Advertise | Sitemap

Home Asp.net MVC Interview Questions

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

11Shares

Page 33 of 33Best 100+ Frequently Asked Interview Questions in .Net SQL

28-04-2016http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server...