Interview Question on (, Database)

What is the difference between the out and ref parameter modifiers?

Answer:Both the out and ref modifiers are used in method arguments. And, both entail that the argument will be passed by reference.

Ref – assignment is needed before passing to the function.
Out – no assignment is required, but you must assign a value in which function this is passed.

The following will not compile:
string sText;
f(ref sText);

The following will compile:
string sText;
g(out sText);

What is the difference between Session Variable and Application variable in ASP.NET?

Answer: ASP.NET Session variables are accessible for a particular user session only, while the Application variables are accessible for all users of the ASP.NET web application.

Compare Session state and Viewstate in .NET?

Answer: Session state is the feature of ASP.NET based web applications using which values of a variable may be persisted and then posted to another page.

Viewstate property of a page or a control, or a viewstate object for a variable value, may also be created to persist its value across a postback. However, the viewstate value are for page level, i.e. they cannot be posted across to another page.

Explain about ExecuteNonQuery,ExecuteReader,ExecuteScalar function.

Answer: ExecuteNonQuery method is used for
Sending SQL Insert statements to a database.
Sending SQL Update statements to a database.
Sending SQL Delete statements to a database.

ExecuteScaler method is used for
Retrieving a single value from a returned row.

ExecuteReader method is used for
Sending SQL Select statements to a database.
Invoking Stored Procedures.

How to Insert,Update and Delete a record into DataTable?

Answer:To insert recorde you will have to create a DataRow object and append
it to the data table…
For Eg
DataRow myRow;
myRow = myDataTable.NewRow();
> myRow.Item[“Col1”] = value;
> or
> myRow[“Col1”] = value;
To update datatable
myDataTable.Rows[0][“Col1”].value = “abc…”; //Thats enough;
To delete from datatable

How to work with dataReader and DataSet?



string sSQL = “SELECT * FROM Products”;
string sConnString =
“Server=(local);Database=Northwind;Integrated Security=SSPI;”;
using (SqlConnection oCn = new SqlConnection(sConnString))
SqlCommand oSelCmd = new SqlCommand(sSQL, oCn);
oSelCmd.CommandType = CommandType.Text;
SqlDataReader oDr = oSelCmd.ExecuteReader();
DataGrid1.DataSource = oDr;

SqlDataReader oDr = oCmd.ExecuteReader();
do {

string sSQL = “SELECT * FROM Products”;
string sConnString =
“Server=(local);Database=Northwind;Integrated Security=SSPI;”;
SqlDataAdapter oDa = new SqlDataAdapter();
DataSet oDs = new DataSet();
using(SqlConnection oCn = new SqlConnection(sConnString))
SqlCommand oSelCmd = new SqlCommand(sSQL, oCn);
oSelCmd.CommandType = CommandType.Text;
oDa.SelectCommand = oSelCmd;
oDa.Fill(oDs, “Products”);

What is difference between dll and exe?

exe is a executable file.
dll is a Dynamic Link Library.

Dll cannot Run on its own
Exe Can Run On its own

Only one .exe file exists per application.

Many .dll files may exists in one application.

ExE There is some Entry point ,Dll There is no entry point .
Exe has main Entry point available
Dll There no any entry point available

DLL Can Occupy own memory space it self
EXE Can allocate memory spaces in different places

Dll Execution is very Fast compare to Exe

Explain the importance of HttpRequest.ValidateInput()?
ValidateInput check the three collections (QueryString, Form, and Cookies) for markup tags to prevent potentially dangerous data like cross site scripting.
If the validation feature is enabled by page directive or configuration, this method is called during the Page’s ProcessRequest processing phase. ValidateInput can be called by your code if the validation feature is not enabled. Request validation works by checking all input data against a hard-coded list of potentially dangerous data.
QueryString, Form, and Cookies input data is checked during request validation.
<%@ Page validation=”true” /“false” %>

How is a strongly-named assembly different from one that isn’t strongly-named?
Strongly-named assemblies are signed using a private\public key pair which helps with code verification.
signed assemblies could be placed in thee GAC.

Can DateTimes be null?
No. It is a Structure an object of it is place in the stack.

Difference between ASP.NET programmer v/s C# prog?

Comparing ASP.NET to C#.NET is like the proverbial apples to oranges comparison.

ASP.NET is a web application framework built on top of the .NET framework (In much the same way as Ruby on Rails is to Ruby, or JSP is to Java).  It can use many (if not any) of the .NET framework languages.  ASP.NET and C#.NET are not mutually exclusive.  I have built web applications, console applications, windows services, and windows forms applications in VB.NET, C#.NET and J#.NET.

If you find a job listing that consider ASP.NET and C#.NET to be “different” then don’t consider taking it.  They clearly don’t know what they are talking about.  I can only assume that these kinds of people and companies consider “C#.NET” to be windows forms programming.

where are session variables stored on client?

Session variables are stored on the server. What is stored in a cookie is
the session id. It is used to restore the session variables on the server
when client’s postback arrives.I believe the only thing stored on the client will be your session ID in a
cookie. The actual data is on the server. The server links the data to the
client via that id.

If you set cookieless=”true” in web.config, your session ID will be embedded
in the URL.

Not sure, but wouldn’t the session cookie be stored C:\Documents and

What is the difference between a class diagram and object diagram?

Ans:Although we design and define classes, in a live application classes are not directly used, but instances or objects of these classes are used for executing the business logic. A pictorial representation of the relationships between these instantiated classes at any point of time (called objects) is called an “Object diagram.” It looks very similar to a class diagram, and uses the similar notations to denote relationships.

If an object diagram and a class diagram look so similar, what is an object diagram actually used for? Well, if you looked at a class diagram, you would not get the picture of how these classes interact with each other at runtime, and in the actual system, how the objects created at runtime are related to the classes. An object diagram shows this relation between the instantiated classes and the defined class, and the relation between these objects, in the logical view of the system. These are very useful to explain smaller portions of your system, when your system class diagram is very complex, and also sometimes recursive.

Let us now see what the components of an object diagram are. After this, we will build an object diagram for our case study—Courseware Management system.

main difference between asp.net2.0,asp.net1.1,asp.net1.0


Master Pages
This new feature provides the ability to define common
structure and interface elements for your site, such as a
page header, footer, or navigation bar, in a common
location called a “master page”, to be shared by many
different pages within your site.

Navigation Control
Provide a common UI for navigating between pages in your
site, such as tree views, menus, and breadcrumbs.

Themes and Skins
This allows for easy customization of a site’s look-and-
feel. You can define style information in a common location
called a “theme” and apply that style information globally
to pages or controls in a site.

New Server Control
ASP.NET 2.0 includes 45 new server controls that enable
powerful declarative support for data access, login
security, wizard navigation, image generation, menus, tree
views, portals and more. Many of the new controls take
advantage of core application services in ASP.NET for
scenarios like data access, membership and roles, and

Data Control
Data access can be accomplished completely declaratively
(without code) using the new data-bound and data source
controls. There are new data source controls to represent

different data backends such as SQL, business objects, and
XML, and there are new data-bound controls for rendering
common UI for data, such as grids, details, and data-bound

ASP.NET 2.0 introduces a lot of new features. Some of this features aim to simplify the problems faced using the earlier versions and some features are introduced to provide lot of new facilities.

The most important features that are incorporated in ASP.NET 2.0 are:

(a) Master Pages
Master pages are introduced to remove one of the most important deficiencies of earlier version of ASP.NET. One thing that has become apparent in the earlier version of ASP.NET is the lack of architecture for applying a consistent look and feel. In earlier version of ASP.NET whenever a developer wants to replicate a common functionality of a web page in other pages, the most possible options he uses is creating a user control and then replicate the functionality in other pages.

ASP.NET 2.0 aims to solve this problem by introducing the concept of Master pages. First the developer needs to define a master page containing the content that he wants to appear on other pages and then use the ContentPlaceHolder controls to define the locations where the sub pages can plug in the content of their own. The he has to build the sub pages – .aspx pages – that reference the master using directives like this one:
<%@Page MasterPageFile = ~/MyMasterPage.master” %>
In addition, an application can designate a default Master Page in web.config as shown here:
<pages masterPageFile=”~/ MyMasterPage.master ” />

(b) PreCompilation
By default, ASP.NET web pages and code files are compiled dynamically when a first request is made to the page. After the initial compilation, the compiled pages is cached; the cache is used to satisfy the subsequent requests for the same page. Even though this approach is flexible, when the page is requested for the first time, it requires a bit of extra time to compile the code. You can avoid this overhead by leveraging a new feature known as precompilation; by using this feature, you can compile an ASP.NET web site before making the web site available to the users.

(c) Sharing code in the application
In earlier version of ASP.NET, if you were to reference a reusable component from your dot net application, you had to compile the assembly and place it in the bin folder (or place it in the GAC) of the web application. But now with ASP.NET 2.0, creating a reusable component is very simple and straightforward. All you need to do is to create a component in a pre-defined subdirectory called code. Any component placed in this directory will be automatically compiled at runtime into a single assembly. This assembly is automatically referenced and will be available to all the page in the site.

(d) Themes and Skins
ASP.NET 2.0 introduces the concepts of Themes and Skins by means of which the look and feel of the web pages can be enhanced to a great extent to make them visually catchy and attractive.

A skin is a set of visual attributes applied to a control type. A theme is a collection of skins. There are a lot of predefined themes in ASP.NET 2.0. One can use it by using the following line of code:
<%@ Page Theme=”SmokeAndGlass” %>
The page directive’s Them attribute declaratively applies a theme to a page. Themes can also be applied programmatically using the page class’s Theme property


4 thoughts on “Interview Question on (, Database)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s