Wednesday, March 12, 2008

Asp.Net Interview Question

Question.How can I change private assembly to shared assembly?
Ans. step1. Get the SN using sn.exe
step2. Add the SN to the Assembly
step3. Put the Assembly in GAC.

Question: What is the difference between an Interface and an Abstract class ?
Answer :An Interface is used to define methods(have no Body) but not for the implementation whereas An abstract class can be used to implement the Methods.
An Interface allows us to use multiple inheritence but not Abstract Classes.
A Class can implement more than one Interface but can be inherited from only one Class.
Interfaces are slow while Abstract classes are fast.

If various implementations shares only share method signature then it is better to use Interface whereas if implementations also use common behaviour then Abstract class is better to use.

Question: Explain CLR ?
The Common Language Runtime(CLR) is most important part of .Net Framework even for .Net Technology. It reduces the amount of code developer need to write because it provides a variety of execution services that include Memory Management, thread Management, component management etc. The key role of CLR is that it provides these execution services to all the applications regardless of what programming they're written in and without any additional effort on the programmer.
The CLR Compiles the code just before execution. Actually Instead of producing a binary representation of code , .Net compilers produces a code in a language which is common to .Net framework (called MSIL means MicroSoft Intermediate Language) . When your source code executes for the first time, CLR invokes a special compiler called Just In Time(JIT) compiler, which converts this MSIL into executable code that is specific to the type and the model of your system's processor.

Question: What is DLL Hell Problem?
DLL Hell points to a Set of problems caused when multiple applications attempt to share a common component like a COM or DLL. The most common and troublesome problem was overwriting a working system DLL with a new version causing some applications to fail.

To understand it well let's take a case. Suppose one application installs a new version of shared component that has not backward compatability with the version that is already on the machine.Although the application that has just been installed works well but the problem arise when existing applications that depends on the previous version might no longer works.

.Net supports strong binding. Strong binding means an application or component can bind to a specific version of a component, so that you can reuse component or use them isolation. When a .Net component is installed onto the machine, the GAC creates a Strong Name for the component. The component is then registered in the repository and indexed by it's strong Name, so there is no confusion between different versions of the same component or DLL.

Question: What is PostBack ?
A postBack is a process in which, when a Page sends a request to the server then the server process the request and Page is submitted to itself.
When a PostBack occurs .......

The current value of controls on Page are contained in the PostBack request and called Post Data.
The content of ViewState are also in the Post Data.
In order to understand PostBack, Page Life Cycle Helps a lot.

Question: List the differences between DataSet and ADO RecordSet ?

RecordSet is Used for a Single table While With DataSet we can work upon multiple tables.
RecordSet is Limited to Single database while DataSet can host tables from multiple databases.
DataSet can also store the relations between the Tables.
A connection should be estabilished every time whenever we work on recordset While DataSet works in disconnected environment.
RecordSet is a concept of ADO while DataSet is a concept of ADO.Net.
DataSet is XML Based.

Question: What is an Assembly and define there types?
An Assembly can be defined as a compiled code library which is used for deployment, versioning and security.It is a logical unit of code which is of two types (1) DLL and (2) EXE.
Even One Assembly can contain many files.
In .Net when you compile your source code then the exe or dll generated is actually an assembly. The information of Assembly is contained in assembly's menifest.

Assembly's are of two types......

Private Assembly : An assembly which is used by a single application is called private assembly. Suppose you created a DLL which contains your Bussiness Logic, then this DLL will be your client application only.
Shared Assembly : Assembly which is used by many appliocations is called shared assembly. It is present in GAC and have a strong name.

Question: What is a Strong Name ?
Answer: A strong name is assembly's Identity which consists assembly's text name, version number , culture information( if provided), public key and a digital signature.
Strong name assemblies are no different from other assemblies except for the fact that they are stored in Global Assembly Cache and could be used across different applications.

Question : Explain View State ?
Answer: View State is a state management property of that retain values across two successive requests for the same page. By default the state is persisted on the client using a hidden field added to the page and is restored on the server before the page request is processed. The View State travels back and forth with the page itself.

Since it's a physical part of the age , it's fast to retrieve and use but it can also become a weakness as it adds a few extra Kb of data as payload. Because it's composed of plain text so it could be tempered and so programmers are not supposed to store sensitive data in the view state (like credit card numbers, passwords etc.).

View State does not hold the controls, rather it holds the values of the form controls and their ID's. It is not used to hold Session data ot to transmit data between pages.

Question: What is GAC ?
Global Assembly Cache is a machine-wide code cache which stores assemblies specifically designated to be shared by several applications on the computer, so that all the applications can use it.

Assemblies should be stored in GAC only when needed, otherwise keep assemblies private and locate in application directory only. Also it is not necessary to install assemblies into GAC to make then available to COM,interop or unmanaged code.

Assemblies deployed in the GAC must have a strong name.When an assembly is added to the Global Assembly Cache, integrity checks are performed on all files.The Integrity checks are performed to ensure that an assembly has not been tempered with , i.e. File has changed but the menifest does not reflect that change.

Question: What is CTS ?
Answer :
Common Type System(CTS) defines how types are declared, used and managed in the runtime and also support cross language Integration and type safety. It defines rules that languages must follow so that they can interact with each other.

Question: What is CLS ?
The Common Language Specification (CLS) is simply a specification that defines the rules to support language integration in such a way that programs written in any language can interoperate with other languages, taking full advantage of inheritance, polymorphism, exception, and other features.

Question: What is the purpose of Global.asax ?
Global.asax is used to define all Session and Application level events, which include Session_Start, Session_End, Application_Start, Application_End and Application_Error events.

Question : What is Portable Executable (PE) ?
PE is a File Format that all Executable Files (EXE) and Dynamic Link Libraries (DLL) must Follow. PE is derived from the Microsoft Common Object File Format (COFF). The exe and dll files created using the .Net Framework obey the PE/COFF formats and also add additional header and data sections to the files that are only used by the CLR.

Question: Name the stages of Page Load Lifecycle ?
There are four Stages......


Question: How many types of directives are in and name them ?
Answer :
There are 9 types of directives and these are.......

@Page directive
@Register directive
@Import directive
@Assembly directive
@Implements directive
@Reference directive
@OutputCache directive
Question: What is the difference between Response.Write( ) and Response.Output.Write( ) ?
Both are used to write output on the page but we can write Formatted output using Response.Output.Write( ).

Question: How will you Perform paging in a DataList control ?
For DataList Paging goto......... Paging in dataList

Question: What is the difference between GridView's DataSourceID property and DataSource property ?
Answer :
DataSourceID property is used to bind GridView to a DataSource control whereas with DataSource property can be used to bind to any object which can include DataSet and DataReader.

Question: What is the use of TemplateField in GridView ?
Answer :
TemplateField is used to define custom column field. User can define his content for each Item in the GridView. One TemplateField is used for one item.

Question: Which Command line tool is used to configure Sql server so that it can support SQL Cache invalidation ?
Answer :
The Command line tool is...


The location of this tool is

For Windows XP....
C:\Windows\Microsoft.Net\Framework\version of .net

For Windows 2000...
C:\Winnt\Microsoft.Net\Framework\version of .net

Question: How do u provide focus in the TextBox control when the page load's ?
Answer :
For Answer please visit the following link...

Default Focus on Page Load

Question: Does HyperLink control support click event ?
Answer :
No. Hyperlink doesn't support click event.To navigate we have to set the NavigateUrl property of the HyperLink.
LinkButton Control supports the click event.

No comments:

Post a Comment