Dot Net Interview Question
1) CLR: Common language runtime
Type checking----------------------to see if valid operations are being performed)
Garbage Collector------------------Automatic memory management
Class loader-----------------------Loads classes into runtime
MSIL to native code compiler-------converts msil to native code
Security Engine--------------------enforces security
Thread Support---------------------Multithreading support
Exception Manager------------------has mechanism to handle run time exceptions
Debug Engine-----------------------allows to debug diff applications
Com Marshaler----------------------Exchange data between .net appliactions and com
2) Private Assembly:
Installed in the web application folder.
Used by only one application.
3) Shared Assembly:
Installed in Global Assembly Cache(GAC)----using gacUtil.exe
Shared by many applications
To be installed in GAC the assembly must be strong named------using sn.exe----provides
a public and a private key for assembly
The key file must be specified in Assembly with AssemblyKeyFileAttribute
4) Enable Postback:
All server controls have this property--------that is to say that the form should be posted
back to the server to process any requests
Html controls by default don't have this-------but can be made to be posted back by
"runat=server" with their declaration
5) Side by side execution:
Assemblies help in side-by-side execution. Each assembly has
1) Assembly metadata-----------------contains info about assembly version (number, build
number, revision number, security id, resources required and scope of assembly) which is
used by CLR to make a decision of which assembly to run.
2) Type Metadata
3) MSIL code----------------without assembly metadata msil code cannot be loaded and
executed by CLR
6) Assemblies r two types:
1) Static-------------1) It is contained in a portable executable. (Which can be dll or exe) it
contains information about types, interfaces and resources.
------------------------2) They r stored on the hard disk
------------------------3)It is created when you compile the program using any .net
------------------------2) not stored on HD
------------------------3) Created during runtime when the application requires types from
------------------------4) System.Reflection.Emit namespaces used in the dynamic creation
7) IsPostBack Method:
It is used when you want to know if the form is posted back for the first time or not.
When you have more data and don't want to do some coding or loading of data every
time the form is posted back.
8) Difference between Array and ArrayList:
Array is used to store only one kind of Data
ArrayList is used to store Different kinds of data or objects.
These are to handle any events from the web form.
Events r to notify some method or object that something has happened.
Events use Delegates to send this notification to receiving methods as they don't know
which method will receive.
Delegate’s r used to store method references in them so that they can call those methods.
The methods which r called must have same signature as delegate (Signature--------return
type, parametrs type) .
Instance methods referred by delegates contain---------Method entry point reference and
reference to object.
Static methods referred by delegates contain------------Method entry point reference only.
Any event which is posted by the form can be handled both by sever and client.
For a server control to handle the client event even before server side code you should
add an attribute for it.
10) Difference between Dataset and DataReader
1) DataSet is disconnected---only connects to database when updating or getting
information from database
-------- DataReader-----Connected to a Database all the time.
2) DataSet ----- U can do any updates or any modification to database using dataset
DataReader ----- is read only
DataReader is better than DataSet
Reason:---------DataReader is forward only, fast and read only.
Must close the DataReader.
Usage depends on how u wants the data to be
1) For example if u have millions of rows of data and want to use it and it is just static
(No change) then u must use DataReader----------as it is just to read data
DataSet can not be used as it loads all the data into memory which is not very efficient in
1) When u use da u don't have to open connection to database explicitly.
U fills the data into dataset using da.
12) DataGrid (dg):
1) For paging (its like when u have more data and it is displayed on multiple pages and u
want pages to be displayed) dg is the better option.
2) You bind the data to dg.
3)You can use BoundColumn property of dg to make any column readonly.---like when u
want user to update using dg but don't want him to change any primary key column
13) SqlCommand --------
U has to explicitly open the connection to database when u uses command. -Error
s14) Overloading (OL) Overriding (OR)
1) Giving same name to methods but 1) Giving same name to many
methods with different signature with same signature
(parameters, return type)
2)There can be multiple methods of 2)Only one method can be overrided
in this type in a single class a class
3)Just changing the return type
of method does not mean OL
For example if u have two text boxes with name and password---------and there r two
required filed validators on those(to see if user has entered any info) and if u leave the
two blank and send click send button then the form will not be posted back.
U can put some value in Initial value property of Required field validator to check if user
has changed that value or not. When user doesn't change a validation will be raised.
The only validation control for which you don't have to specify any control to validate is
Custom validate control.
16) Differences between Asp and Asp.net
1)asp--------code was interpreted
asp.net------code is compiled so better performance
2)asp--------few server controls
asp.net------server controls like datagrid, validation controls,list boxes
17) How can you isolate a project that is running on the same web server as other
projects? The project is a must.
Basically u have three kinds of processing env to run .net applications.
1) Within IIS inetinfo.exe------which can effect iis as it is in the same process
2)pooled with other applications in dllhost.exe-----default. even if any damage can affect
any process but not inetinfo.exe
3)separate dllhost.exe---------no affect on any process
1)within---------------better cuz all calls r in process
2)pooled---------------not better than 1
3)isolated-------------very poor since all calls r out of process
u can isolate that project with this or else you have isolate in IIS properties which helps in
doing this. When you check this and restart the server it will actually load that project
into MTS explorer so MTS takes care of any damages.
18) How can you say that a control like checkbox or anything when checked that it
refers to that particular form or id of employee or anything
U can provide the control with id, which in turn can be checked.
19) Webservices def
XML Web services are applications that provide the ability to exchange messages in a
loosely coupled environment using standard protocols such as HTTP, XML, XSD,
SOAP, and WSDL. XML Web service enables the building of modular applications
within and across companies in heterogeneous environments making them interoperable
with a broad variety of implementations, platforms and devices.
20) When you overload methods in web services, is there any mechanism to
differentiate between them using soap.
U can specify MessageName attribute, which will be used by soap.
21) Other general possible questions related to ur resume
1)What was the project that u worked on recently
3)What role did you play in it
4)What r the main components that u were working on
5)were you there from beginning to the end of project
6)what kind of problem did you face during those project development related to the
components and techniques u have used
7)How did you resolve those problems
22) Two disadvantages by calling COM components from web services
1) have to marshal the data between com and .net that is performance degradance.
23) what r static constructors
Static constructors r used in initializing the class itself. They r executed when the class
loads for the first time. They cannot have any parameters.
24) What is the best class to use for string related operations in Asp.net and what is
the difference between using this and other classes
U can use StringBuilder for better performance. When u add two strings with +(s1+s2)
the actual thing that happens inside is that those two string r destroyed (as string are
immutable)and a new string which contains both contents of those string will be created.
It is time consuming since there is a creation of object involved where with stringbuilder
this is not the case.
25) what is Stackalloc
Allocates a block of memory on the stack. the address of the block is stored in pointer
ptr. This memory is not subject to garbage collection and therefore does not have to be
pinned (via fixed). The lifetime of the memory block is limited to the lifetime of the
method in which it is defined.
26) explain why we use exception handling
To catch any unknown exception or any exceptions that might cause the program to end
27) How do you configure security in asp.net
Using Web.Config authentication section…mode=”forms/windows/passport”
28) Can you import code from vb.net
29) what is the benefit of it
Vb is better for developing UserInterface and besides any previously coded code can be
used as both of them have CLS (common language specification)
30) How many cluster indexed can we have on a table
31) How does a cluster index store keys
It actually stores the data physically. It uses BTrees in this process. So if you have
clustered indexes then even if you have other non clustered indexes the data will be
stored according to clustered index.
32) Can we make a stored procedure run everytime we call it…lets say in an env
where the data chages always.
Yes, you can…Using With Recompile option in the creation of the stored procedure.
33) What namespace do you use for exceptions in asp.net?
34) How do you handle exception in asp
Using AspError object
35) Can we have multiple catch blocks for one try block/Flow of Exception block
Yes …we can…if you specify a particular catch block which contains info about the
exception then that will be executed. If not the most general catch block will be executed.
Any how the finally block will be executed all the time. Try…specific exception---if not
36) How many authentication types r there in asp.net
3---forms,passport and windows…you specify this info in web.config
37) What is a user control
User control is something that combines two or more controls to give them a single visual
appearance. And it is reusable. So, for example if u need to ask the user to enter address
details then u have to put all the controls like name,city,zip and all of those on every form
where u need it and code it. But instead what if u have something which will have all this
functionality combined in one control and the only thing u have to do then is just to drag
it from the toolbox and drop it where it is needed. U r not only combining more controls
into one but u r also having the necessary functionality wherever u need.
38) Can you store info about server control and how
Yes…Using Viewstate u can store info…Viewstate hashes the info, which prevents any
corruption to the data, and this data can be retrieved when webform Is posted back to get
info about controls.
39) Difference between server.transfer and server.execute
Server.Transfer transfers some info to the other web form and beside it gives the
executing capability to that webform.
Server.Execute doesn’t give executing capability to the other web form.
40) What is ExecuteScalar and how does it work
You can update data in database directly without using DataAdapter using Executescalar,
ExecuteNonQuery and ExecuteReader.
ExecuteScalar returns a single value such as a count of employees or so. Even if u get
multiple values from database it will return only the first row first column value.
41) How does Machine.config defer from Web.config
Any changes in Machine.config effect all the applications running on that machine where
as any changes to web.config affect only a particular application. However web.config
overrides any settings in machine.config.
42) What if there is static data and you want better performance.
U can take that info into a cache object and use it.
43) What is impersonation? What is the default account that is used by IIS?
Providing an unknown user with some kind of identification or account is called
44) Why do you need Passport authentication?
When you don’t want user to remember all the user names and password for all the sites
that u r hosting u need passport authentication.
It will store a profile for the user and helps user in using only one username/password to
enter all the sites.
45) What is the deference between GenericPrincipal and WindowsPrincipal
Generic principal contains null info about the role of the user
Windowsprincipal contains Windows role of the user.
46) What information does satellite assemblies contain/how do they defer from main
Satellite assemblies contain only resources where as main assembly contains assembly
manifest---version info,security, MSIL code and type metadata.
U use al.exe to make assemblies from resource files.
47) What is the tool used to give strong name to assembly?
Sn.exe---if u want to delay the key file adding to assembly you can specify –delay in that.
48) How do you install assembly in GAC?
49) How do you make a method accessible/ to be called by clients in Web services
Using WebMethod attribute
50) How can u access or modify any info coming from the client in web services
U have to create a class which inherits from SoapExtension or implements IHttpHandler
to get information from client and you can do like---checking for security in there.
But u should however have to create a new object, which references that info.