0% found this document useful (0 votes)
46 views

Interview Questions

The document discusses various ASP.NET concepts and technologies including XHTML compliance, viewstate, master pages, themes, web services, and application pools. It also compares C# and VB.NET and defines terms like base class, derived class, inheritance, and implementation inheritance.

Uploaded by

GouravPant
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)
46 views

Interview Questions

The document discusses various ASP.NET concepts and technologies including XHTML compliance, viewstate, master pages, themes, web services, and application pools. It also compares C# and VB.NET and defines terms like base class, derived class, inheritance, and implementation inheritance.

Uploaded by

GouravPant
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/ 13

What is XHTML? Are ASP.NET Pages compliant with XHTML?

In simple words, XHTML is a stricter and cleaner version of HTML. XHTML


stands for Extensible Hypertext Markup Language and is a W3C
Recommendation.
Yes, ASP.NET 2.0 Pages are XHTML compliant. However the freedom has been
given to the user to include the appropriate document type declaration.
Can I deploy the application without deploying the source code on
the server?
Yes. You can obfuscate your code by using a new pre-compilation process
called pre-compilation for deployment. You can use the aspnet_compiler.exe
to pre-compile a site. This process builds each page in your web application
into a single application DLL and some placeholder files. These files can then
be deployed to the server.
You can also accomplish the same task using Visual Studio 2005 by using the
Build->Publish menu.
Does ViewState affect performance? What is the ideal size of a
ViewState? How can you compress a viewstate?
Viewstate stores the state of controls in HTML hidden fields. At times, this
information can grow in size. This does affect the overall responsiveness of
the page, thereby affecting performance. The ideal size of a viewstate should
be not more than 25-30% of the page size.
Viewstate can be compressed to almost 50% of its size. .NET also provides
the GZipStream or Deflate Stream to compress viewstate. Another option
is explained by Scott Hanselmann over here.
How can you detect if a viewstate has been tampered?
By setting the EnableViewStateMac to true in the @Page directive. This
attribute checks the encoded and encrypted viewstate for tampering.
Can I use different programming languages in the same application?
Yes. Each page can be written with a different programming language in the
same application. You can create a few pages in C# and a few in VB.NET.
Can the App_Code folder contain source code files in different
programming languages?
No. All source code files kept in the root App_Code folder must be in the
same programming language.
Update: However, you can create two subfolders inside the App_Code and
then add both C# and VB.NET in the respective subfolders. You also have to
add configuration settings in the web.config for this to work.
How do you secure your connection string information?
By using the Protected Configuration feature.

How do you secure your configuration files to be accessed remotely


by unauthorized users?
ASP.NET configures IIS to deny access to any user that requests access to the
Machine.config or Web.config files.
How can I configure ASP.NET applications that are running on a
remote machine?
You can use the Web Site Administration Tool to configure remote websites.
How many web.config files can I have in an application?
You can keep multiple web.config files in an application. You can place a
Web.config file inside a folder or wherever you need (apart from some
exceptions) to override the configuration settings that are inherited from a
configuration file located at a higher level in the hierarchy.
I have created a configuration setting in my web.config and have
kept it at the root level. How do I prevent it from being overridden
by another web.config that appears lower in the hierarchy?
By setting the element's Override attribute to false.
What is the difference between Response.Write and
Response.Output.Write?
As quoted by Scott Hanselman, the short answer is that the latter gives you
String.Format-style output and the former doesn't.
What is Cross Page Posting? How is it done?
By default, ASP.NET submits a form to the same page. In cross-page posting,
the form is submitted to a different page. This is done by setting the
PostBackUrl property of the button (that causes postback) to the desired
page. In the code-behind of the page to which the form has been posted, use
the FindControl method of the PreviousPage property to reference the data
of the control in the first page.
Can you change a Master Page dynamically at runtime? How?
Yes. To change a master page, set the MasterPageFile property to point to the
.master page during the PreInit page event.
How do you apply Themes to an entire application?
By specifying the theme in the web.config file.
<Configuration>
<system.web>
<pages theme=BlueMoon />
</system.web>
</configuration>
How do you exclude an ASP.NET page from using Themes?

To remove themes from your page, use the EnableTheming attribute of the
Page directive.
Your client complains that he has a large form that collects user
input. He wants to break the form into sections, keeping the
information in the forms related. Which control will you use?
The ASP.NET Wizard Control.
Do WebServices support data reader?
No. However it does support a dataset.
What is use of the AutoEventWireup attribute in the Page directive?
The AutoEventWireUp is a boolean attribute that allows automatic wireup of
page events when this attribute is set to true on the page. It is set to True by
default for a C# web form whereas it is set as False for VB.NET forms. Pages
developed with Visual Studio .NET have this attribute set to false, and page
events are individually tied to handlers.
What happens when you change the web.config file at run time?
ASP.NET invalidates the existing cache and assembles a new cache. Then
ASP.NET automatically restarts the application to apply the changes.
Can you programmatically access IIS configuration settings?
Yes. You can use ADSI, WMI, or COM interfaces to configure IIS
programmatically.
How does Application Pools work in IIS 6.0?
As explained under the IIS documentation, when you run IIS 6.0 in worker
process isolation mode, you can separate different Web applications and Web
sites into groups known as application pools. An application pool is a group of
one or more URLs that are served by a worker process or set of worker
processes. Any Web directory or virtual directory can be assigned to an
application pool.
Every application within an application pool shares the same worker
process. Because each worker process operates as a separate instance of the
worker process executable, W3wp.exe, the worker process that services one
application pool is separated from the worker process that services another.
Each separate worker process provides a process boundary so that when an
application is assigned to one application pool, problems in other application
pools do not affect the application. This ensures that if a worker process fails,
it does not affect the applications running in other application pools.

Use multiple application pools when you want to help ensure that
applications and Web sites are confidential and secure. For example, an
enterprise organization might place its human resources Web site and its
finance Web site on the same server, but in different application pools.
Likewise, an ISP that hosts Web sites and applications for competing
companies might run each company Web services on the same server, but in
different application pools. Using different application pools to isolate
applications helps prevent one customer from accessing, changing, or using
confidential information from another customer site.
In HTTP.sys, an application pool is represented by a request queue, from
which the user-mode worker processes that service an application pool
collect the requests. Each pool can manage requests for one or more unique
Web applications, which you assign to the application pool based on their
URLs. Application pools, then, are essentially worker process configurations
that service groups of namespaces.
Multiple application pools can operate at the same time. An application, as
defined by its URL, can only be served by one application pool at any time.
While one application pool is servicing a request, you cannot route the
request to another application pool. However, you can assign applications to
another application pool while the server is running.
What is an application server?
As defined in Wikipedia, an application server is a software engine that
delivers applications to client computers or devices. The application server
runs your server code. Some well known application servers are IIS
(Microsoft), WebLogic Server (BEA), JBoss (Red Hat), WebSphere (IBM).
Compare C# and VB.NET
What is a base class and derived class?
A class is a template for creating an object. The class from which other
classes derive fundamental functionality is called a base class. For e.g. If
Class Y derives from Class X, then Class X is a base class.
The class which derives functionality from a base class is called a derived
class. If Class Y derives from Class X, then Class Y is a derived class.
What is an extender class?

An extender class allows you to extend the functionality of an existing


control. It is used in Windows forms applications to add properties to
controls.
What is inheritance?
Inheritance represents the relationship between two classes where one type
derives functionality from a second type and then extends it by adding new
methods, properties, events, fields and constants.

C# support two types of inheritance:


Implementation inheritance
Interface inheritance
What is implementation and interface inheritance?
When a class (type) is derived from another class(type) such that it inherits
all the members of the base type it is Implementation Inheritance.
When a type (class or a struct) inherits only the signatures of the functions
from another type it is Interface Inheritance.
In general Classes can be derived from another class, hence support
Implementation inheritance. At the same time Classes can also be derived
from one or more interfaces. Hence they support Interface inheritance.
What is inheritance hierarchy?
The class which derives functionality from a base class is called a derived
class. A derived class can also act as a base class for another class. Thus it is
possible to create a tree-like structure that illustrates the relationship
between all related classes. This structure is known as the inheritance
hierarchy.
How do you prevent a class from being inherited?
In VB.NET you use the Not Inheritable modifier to prevent programmers
from using the class as a base class. In C#, use the sealed keyword.
When should you use inheritance?
Read this.
Define Overriding?
Overriding is a concept where a method in a derived class uses the same
name, return type, and arguments as a method in its base class. In other
words, if the derived class contains its own implementation of the method
rather than using the method in the base class, the process is called
overriding.
Can you use multiple inheritances in .NET?
.NET supports only single inheritance. However the purpose is accomplished
using multiple interfaces.
Why dont we have multiple inheritances in .NET?
There are several reasons for this. In simple words, the efforts are more,
benefits are less. Different languages have different implementation

requirements of multiple inheritance. So in order to implement multiple


inheritance, we need to study the implementation aspects of all the
languages that are CLR compliant and then implement a common
methodology of implementing it. This is too much of efforts. Moreover
multiple interface inheritance very much covers the benefits that multiple
inheritance has.
What is an Interface?
An interface is a standard or contract that contains only the signatures of
methods or events. The implementation is done in the class that inherits
from this interface. Interfaces are primarily used to set a common standard
or contract.
What are events and delegates?
An event is a message sent by a control to notify the occurrence of an action.
However it is not known which object receives the event. For this reason,
.NET provides a special type called Delegate which acts as an intermediary
between the sender object and receiver object.
What is business logic?
It is the functionality which handles the exchange of information between
database and a user interface.
What is a component?
Component is a group of logically related classes and methods. A component
is a class that implements the IComponent interface or uses a class that
implements IComponent interface.
What is a control?
A control is a component that provides user-interface (UI) capabilities.
What are design patterns?
Design patterns are common solutions to common design problems.
What is a connection pool?
A connection pool is a collection of connections which are shared between
the clients requesting one. Once the connection is closed, it returns back to
the pool. This allows the connections to be reused.
What is a flat file?
A flat file is the name given to text, which can be read or written only
sequentially.
What is the global assembly cache (GAC)?
GAC is a machine-wide cache of assemblies that allows .NET applications to
share libraries. GAC solves some of the problems associated with .dll (DLL
Hell).
What is a stack? What is a heap? Give the differences between the
two?
Stack is a place in the memory where value types are stored. Heap is a place
in the memory where the reference types are stored.
What is instrumentation?

It is the ability to monitor an application so that information about the


applications progress, performance and status can be captured and
reported.
What is logging?
Logging is the process of persisting information about the status of an
application.
What are mock-ups?
Mock-ups are a set of designs in the form of screens, diagrams, snapshots
etc., that helps verify the design and acquire feedback about the
applications requirements and use cases, at an early stage of the design
process.
What is a Form?
A form is a representation of any window displayed in your application. Form
can be used to create standard, borderless, floating, modal windows.
What is a single-document interface (SDI) ?
A user interface that is created to manage graphical user interfaces and
controls into single windows. E.g. Microsoft Word
What is BLOB ?
A BLOB (binary large object) is a large item such as an image or an exe
represented in binary form.
What is ClickOnce?
ClickOnce is a new deployment technology that allows you to create and
publish self-updating applications that can be installed and run with minimal
user interaction.
What is object role modeling (ORM)?
It is a logical model for designing and querying database models. There are
various ORM tools in the market like CaseTalk, Microsoft Visio for Enterprise
Architects, Infagon etc.
What is a private assembly?
A private assembly is local to the installation directory of an application and
is used only by that application.
What is a shared assembly?
A shared assembly is kept in the global assembly cache (GAC) and can be
used by one or more applications on a machine.
What is the difference between user and custom controls?
User controls are easier to create whereas custom controls require extra
effort.
User controls are used when the layout is static whereas custom controls are
used in dynamic layouts.
A user control cannot be added to the toolbox whereas a custom control can
be.

A separate copy of a user control is required in every application that uses it


whereas since custom controls are stored in the GAC, only a single copy can
be used by all applications.
Where do custom controls reside?
In the global assembly cache (GAC).
What is a third-party control?
A third-party control is one that is not created by the owners of a project.
They are usually used to save time and resources and reuse the functionality
developed by others (third-party).
What is a binary formatter?
Binary formatter is used to serialize and deserialize an object in binary
format.
What is a COM Callable Wrapper (CCW)?
CCW is a wrapper created by the common language runtime (CLR) that
enables COM components to access .NET objects.
What is a Runtime Callable Wrapper (RCW)?
RCW is a wrapper created by the common language runtime(CLR) to
enable .NET components to call COM components.
What is a digital signature?
A digital signature is an electronic signature used to verify/guarantee the
identity of the individual who is sending the message.
What is globalization?
Globalization is the process of customizing applications that support multiple
cultures and regions.
What is localization?
Localization is the process of customizing applications that support a given
culture and regions.
What is MIME?
The definition of MIME or Multipurpose Internet Mail Extensions as stated in
MSDN is MIME is a standard that can be used to include content of various
types in a single message. MIME extends the Simple Mail Transfer Protocol
(SMTP) format of mail messages to include multiple content, both textual and
non-textual. Parts of the message may be images, audio, or text in different
character sets.

RIGHT JOIN or RIGHT OUTER JOIN - A right outer join is the reverse
of a left outer join. All rows from the right table are returned. Null

values are returned for the left table any time a right table row has
no matching row in the left table.
FULL JOIN or FULL OUTER JOIN - A full outer join returns all rows in
both the left and right tables. Any time a row has no match in the
other table, the select list columns from the other table contain null
values. When there is a match between the tables, the entire result
set row contains data values from the base tables.
Cross joins - Cross joins return all rows from the left table, each
row from the left table is combined with all rows from the right
table. Cross joins are also called Cartesian products. (A Cartesian
join will get you a Cartesian product. A Cartesian join is when you
join every row of one table to every row of another table. You can
also get one by joining every row of a table to every row of itself.)
46. What are the differences between UNION and JOINS?
A join selects columns from 2 or more tables. A union selects rows.
47. Can I improve performance by using the ANSI-style joins instead
of
the old-style joins?
Code Example 1:
select o.name, i.name
from sysobjects o, sysindexes i
where o.id = i.id
Code Example 2:
select o.name,
i.name
from sysobjects o inner join sysindexes i
on o.id = i.id
You will not get any performance gain by switching to the ANSI-style
JOIN syntax.
Using the ANSI-JOIN syntax gives you an important advantage: Because
the join logic is cleanly separated from the filtering criteria, you
can understand the query logic more quickly.

The SQL Server old-style JOIN executes the filtering conditions before
executing the joins, whereas the ANSI-style JOIN reverses this
procedure (join logic precedes filtering).
Perhaps the most compelling argument for switching to the ANSI-style
JOIN is that Microsoft has explicitly stated that SQL Server will not
support the old-style OUTER JOIN syntax indefinitely. Another
important consideration is that the ANSI-style JOIN supports query
constructions that the old-style JOIN syntax does not support.
48. What is derived table?
Derived tables are SELECT statements in the FROM clause referred to by
an alias or a user-specified name. The result set of the SELECT in the
FROM clause forms a table used by the outer SELECT statement. For
example, this SELECT uses a derived table to find if any store carries
all book titles in the pubs database:
SELECT ST.stor_id, ST.stor_name
FROM stores AS ST,
(SELECT stor_id, COUNT(DISTINCT title_id) AS title_count
FROM sales
GROUP BY stor_id
) AS SA
WHERE ST.stor_id = SA.stor_id
AND SA.title_count = (SELECT COUNT(*) FROM titles)
What are locks?
Microsoft SQL Server 2000 uses locking to ensure transactional
integrity and database consistency. Locking prevents users from
reading data being changed by other users, and prevents multiple users
from changing the same data at the same time. If locking is not used,
data within the database may become logically incorrect, and queries
executed against that data may produce unexpected results.

75. What are the different types of locks?


SQL Server uses these resource lock modes.
Lock mode Description
Shared (S) Used for operations that do not change or update data
(read-only operations), such as a SELECT statement.
Update (U) Used on resources that can be updated. Prevents a common
form of deadlock that occurs when multiple sessions are reading,
locking, and potentially updating resources later.
Exclusive (X) Used for data-modification operations, such as INSERT,
UPDATE, or DELETE. Ensures that multiple updates cannot be made to the
same resource at the same time.
Intent Used to establish a lock hierarchy. The types of intent locks
are: intent shared (IS), intent exclusive (IX), and shared with intent
exclusive (SIX).
Schema Used when an operation dependent on the schema of a table is
executing. The types of schema locks are: schema modification (Sch-M)
and schema stability (Sch-S).
Bulk Update (BU) Used when bulk-copying data into a table and the
TABLOCK hint is specified.
76. What is a dead lock? Give a practical sample? How you can
minimize
the deadlock situation? What is a deadlock and what is a live lock?
How will you go about resolving deadlocks?
Deadlock is a situation when two processes, each having a lock on one
piece of data, attempt to acquire a lock on the other's piece. Each
process would wait indefinitely for the other to release the lock,
unless one of the user processes is terminated. SQL Server detects
deadlocks and terminates one user's process.
A livelock is one, where a request for an exclusive lock is
repeatedly denied because a series of overlapping shared locks keeps
interfering. SQL Server detects the situation after four denials and

refuses further shared locks. A livelock also occurs when read


transactions monopolize a table or page, forcing a write transaction
to wait indefinitely.
71. What is Trigger? What is its use? What are the types of Triggers?
What are the new kinds of triggers in sql 2000? When should one use
"instead of Trigger"?
Microsoft SQL Serve 2000 triggers are a special class of stored procedure
defined to execute automatically when an UPDATE, INSERT, or DELETE
statement is issued against a table or view. Triggers are powerful tools that
sites can use to enforce their business rules
automatically when data is modified.
The CREATE TRIGGER statement can be defined with the FOR UPDATE, FOR
INSERT, or FOR DELETE clauses to target a trigger to a specific class of data
modification actions. When FOR UPDATE is specified, the IF UPDATE
(column_name) clause can be used to target a trigger to updates affecting a
particular column.
You can use the FOR clause to specify when a trigger is executed:
AFTER - The trigger executes after the statement that triggered it
completes. If the statement fails with an error, such as a constraint
violation or syntax error, the trigger is not executed. AFTER triggers
cannot be specified for views, they can only be specified for tables.
You can specify multiple AFTER triggers for each triggering action
(INSERT, UPDATE, or DELETE). If you have multiple AFTER triggers for a
table, you can use sp_settriggerorder to define which AFTER trigger
fires first and which fires last. All other AFTER triggers besides the
first and last fire in an undefined order which you cannot control.
AFTER is the default in SQL Server 2000. You could not specify AFTER
or INSTEAD OF in SQL Server version 7.0 or earlier, all triggers in
those versions operated as AFTER triggers.
INSTEAD OF -The trigger executes in place of the triggering action.
INSTEAD OF triggers can be specified on both tables and views. You can
define only one INSTEAD OF trigger for each triggering action (INSERT,
UPDATE, and DELETE). INSTEAD OF triggers can be used to perform

enhance integrity checks on the data values supplied in INSERT and


UPDATE statements. INSTEAD OF triggers also let you specify actions
that allow views, which would normally not support updates, to be
updatable.
An INSTEAD OF trigger can take actions such as:
Ignoring parts of a batch.
Not processing a part of a batch and logging the problem rows.
Taking an alternative action if an error condition is encountered.
In SQL Server 6.5 you could define only 3 triggers per table, one for
INSERT, one for UPDATE and one for DELETE. From SQL Server 7.0
onwards, this restriction is gone, and you could create multiple
triggers per each action. But in 7.0 there's no way to control the
order in which the triggers fire. In SQL Server 2000 you could specify
which trigger fires first or fires last using sp_settriggerorder.
Triggers can't be invoked on demand. They get triggered only when an
associated action (INSERT, UPDATE, DELETE) happens on the table on
which they are defined.
Triggers are generally used to implement business rules, auditing.
Triggers can also be used to extend the referential integrity checks,
but wherever possible, use constraints for this purpose, instead of
triggers, as constraints are much faster. Till SQL Server 7.0,
triggers fire only after the data modification operation happens. So
in a way, they are called post triggers. But in SQL Server 2000 you
could create pre triggers also.

You might also like