This is a list of questions I have gathered and created over a
period of time from my experience, many of which I felt where incomplete
or simply wrong. I have finally taken the time to go through each
question and correct them to the best of my ability. However, please feel
free to post feedback to challenge, improve, or suggest new questions. I
want to thank those of you that have contributed quality questions and
corrections thus far.
There are some questions in this list that I do not consider to
be good questions for an interview. However, they do exist on other lists
available on the Internet so I felt compelled to keep them here for easy
access.
1.
Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe
in the page loading process.
inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests
among other things.When an ASP.NET request is received (usually a file with
.aspx extension), the ISAPI filter aspnet_isapi.dll takes care of it by passing
the request tothe actual worker process aspnet_wp.exe.
2.
What’s the difference between Response.Write()
andResponse.Output.Write()?
Response.Output.Write()
allows you to write formatted output.
3.
What methods are fired during the page load?
Init()
- when the page is instantiated
Load() - when the page is loaded into server memory
PreRender() - the brief moment before the page is displayed to the user as HTML
Unload() - when page finishes loading.
4.
When during the page processing cycle
is ViewState available?
After the Init() and before the Page_Load(), or OnLoad() for a control.
5.
What namespace does the Web page belong in the .NET Framework
class hierarchy?
System.Web.UI.Page
6.
Where do you store the information about the user’s locale?
System.Web.UI.Page.Culture
7.
What’s the difference between
Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?
CodeBehind
is relevant to Visual Studio.NET only.
8.
What’s a bubbled event?
When
you have a complex control, like DataGrid, writing an event processing routine
for each object (cell, button, row, etc.) is quite tedious. The controls can
bubble up their eventhandlers, allowing the main DataGrid event handler to take
care of its constituents.
9.
Suppose you want a certain ASP.NET function executed on
MouseOver for a certain button. Where do you add an event
handler?
Add
an OnMouseOver attribute to the button. Example:
btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();");
10.
What data types do the RangeValidator control support?
Integer,
String, and Date.
11.
Explain the differences between Server-side and Client-side
code?
Server-side
code executes on the server. Client-side code executes in the
client's browser.
12.
What type of code (server or client) is found in a Code-Behind
class?
The
answer is server-side code since code-behind is executed on the server.
However, during the code-behind's execution on the server, it can render
client-side code such as JavaScript to be processed in the
clients browser. But just to be clear, code-behind executes on the
server, thus making it server-side code.
13.
Should user input data validation occur server-side or
client-side? Why?
All
user input data validation should occur on the server at a minimum.
Additionally, client-side validation can be performed where deemed appropriate
and feasable to provide a richer, more responsive experience for the
user.
14.
What is the difference between Server.Transfer and
Response.Redirect? Why would I choose one over the other?
Server.Transfer
transfers page processing from one page directly to the next page
without making a round-trip back to the client's browser. This provides a
faster response with a little less overhead on the server.
Server.Transfer does not update the clients url history list or
current url. Response.Redirect is used to redirect the user's
browser to another page or site. This performas a trip back to the
client where the client's browser is redirected to the new page. The
user's browser history list is updated to reflect the new address.
15.
Can you explain the difference between an ADO.NET Dataset and an
ADO Recordset?
Valid
answers are:
· A DataSet can represent an entire relational database in memory,
complete with tables, relations, and views.
· A DataSet is designed to work without any continuing connection to the
original data source.
· Data in a DataSet is bulk-loaded, rather than being loaded on demand.
· There's no concept of cursor types in a DataSet.
· DataSets have no current record pointer You can use For Each loops to
move through the data.
· You can store many edits in a DataSet, and write them to the original
data source in a single operation.
· Though the DataSet is universal, other objects in ADO.NET come in
different versions for different data sources.
16.
What is the Global.asax used for?
The
Global.asax (including the Global.asax.cs file) is used to implement
application and session level events.
17.
What are the Application_Start and Session_Start
subroutines used for?
This
is where you can set the specific variables for the Application and Session
objects.
18.
Can you explain what inheritance is and an example of when you
might use it?
When
you want to inherit (use the functionality of) another class. Example: With
a base class named Employee, a Manager class could be derived from the
Employee base class.
19.
Whats an assembly?
Assemblies
are the building blocks of the .NET framework.
Overview of assemblies from MSDN
20.
Describe the difference between inline and code behind.
Inline
code written along side the html in a page. Code-behind is code written in a
separate file and referenced by the .aspx page.
21.
Explain what a diffgram is, and a good use for one?
The
DiffGram is one of the two XML formats that you can use to render DataSet
object contents to XML. A good use is reading database data to an
XML file to be sent to a Web Service.
22.
Whats MSIL, and why should my developers need an appreciation of
it if at all?
MSIL
is the Microsoft Intermediate Language. All .NET compatible languages will get
converted to MSIL. MSIL also allows the .NET Framework to JIT compile the
assembly on the installed computer.
23.
Which method do you invoke on the DataAdapter control to load
your generated dataset with data?
The
Fill() method.
24.
Can you edit data in the Repeater control?
No,
it just reads the information from its data source.
25.
Which template must you provide, in order to display data in a
Repeater control?
ItemTemplate.
26.
How can you provide an alternating color scheme in a Repeater
control?
Use
the AlternatingItemTemplate.
27.
What property must you set, and what method must you call in
your code, in order to bind the data from a data source to the Repeater
control?
You
must set the DataSource property and call the DataBind method.
28.
What base class do all Web Forms inherit from?
The
Page class.
29.
Name two properties common in every validation control?
ControlToValidate
property and Text property.
30.
Which property on a Combo Box do you set with a column name,
prior to setting the DataSource, to display data in the combo box?
DataTextField
property.
31.
Which control would you use if you needed to make sure the
values in two different controls matched?
CompareValidator
control.
32.
How many classes can a single .NET DLL contain?
It
can contain many classes.
Web Service Questions
1.
What is the transport protocol you use to call a Web service?
SOAP (Simple
Object Access Protocol) is the preferred protocol.
2.
True or False: A Web service can only be written in .NET?
False
3.
What does WSDL stand for?
Web
Services Description Language.
4.
Where on the Internet would you look for Web services?
http://www.uddi.org
5.
True or False: To test a Web service you must create a Windows
application or Web application to consume this service?
False,
the web service comes with a test page and it provides HTTP-GET method to test.
State Management Questions
1.
What is ViewState?
ViewState
allows the state of objects (serializable) to be stored in a hidden field on
the page. ViewState is transported to the client and back to the server,
and is not stored on the server or any other external source. ViewState
is used the retain the state of server-side objects between postabacks.
2.
What is the lifespan for items stored in ViewState?
Item
stored in ViewState exist for the life of the current page. This includes
postbacks (to the same page).
3.
What does the "EnableViewState" property
do? Why would I want it on or off?
It
allows the page to save the users input on a form across postbacks. It
saves the server-side values for a given control into ViewState, which is
stored as a hidden value on the page before sending the page to the clients
browser. When the page is posted back to the server the server
control is recreated with the state stored in viewstate.
4.
What are the different types of Session state
management options available with ASP.NET?
ASP.NET provides In-Process and Out-of-Process state management.
In-Process stores the session in memory on the web server. This requires
the a "sticky-server" (or no load-balancing) so that the user is
always reconnected to the same web server. Out-of-Process Session state
management stores data in an external data source. The external data
source may be either a SQL Server or a State Server service. Out-of-Process
state management requires that all objects stored in session are serializable.
.NET Remoting Interview
Questions
To Do: Comfirm these are correct answers. Many
of these question I have obtained from other sources and have found they are
not entirely correct, or simply wrong.
1.
What’s a Windows process?
It’s
an application that’s running and had been allocated memory.
2.
What’s typical about a Windows process in regards to memory
allocation?
Each
process is allocated its own block of available RAM space, no process can
access another process’ code or data. If the process crashes, it dies alone
without taking the entire OS or a bunch of other applications down.
3.
Explain what relationship is between a Process, Application
Domain, and Application?
A
process is an instance of a running application. An application is an
executable on the hard drive or network. There can be numerous processes
launched of the same application (5 copies of Word running), but 1 process can
run just 1 application.
4.
What are possible implementations of distributed applications in
.NET?
.NET Remoting and ASP.NET Web Services. If we talk
about the Framework Class Library, noteworthy classes are in
System.Runtime.Remoting and System.Web.Services.
5.
What are the consideration in deciding to use .NET
Remoting or ASP.NET Web Services?
Remoting
is a more efficient communication exchange when you can control both ends of
the application involved in the communication process. Web Services
provide an open-protocol-based exchange of informaion. Web Services are
best when you need to communicate with an external organization or another
(non-.NET) technology.
6.
What’s a proxy of the server object in .NET Remoting?
It’s
a fake copy of the server object that resides on the client side and behaves as
if it was the server. It handles the communication between real server object
and the client object. This process is also known as marshaling.
7.
What are remotable objects in .NET Remoting?
Remotable
objects are the objects that can be marshaled across the application domains.
You can marshal by value, where a deep copy of the object is created and then
passed to the receiver. You can also marshal by reference, where just a
reference to an existing object is passed.
8.
What are channels in .NET Remoting?
Channels
represent the objects that transfer the other serialized objects from one
application domain to another and from one computer to another, as well as one
process to another on the same box. A channel must exist before an object can
be transferred.
9.
What security measures exist for .NET Remoting in
System.Runtime.Remoting?
None.
Security should be taken care of at the application level. Cryptography and
other security techniques can be applied at application or server level.
10.
What is a formatter?
A
formatter is an object that is responsible for encoding and serializing data
into messages on one end, and deserializing and decoding messages into data on
the other end.
11.
Choosing between HTTP and TCP for protocols and Binary and SOAP
for formatters, what are the trade-offs?
Binary
over TCP is the most effiecient, SOAP over HTTP is the most interoperable.
12.
What’s SingleCall activation mode used for?
If
the server object is instantiated for responding to just one single request,
the request should be made in SingleCall mode.
13.
What’s Singleton activation mode?
A
single object is instantiated regardless of the number of clients accessing it.
Lifetime of this object is determined by lifetime lease.
14.
How do you define the lease of the object?
By
implementing ILease interface when writing the class code.
15.
Can you configure a .NET Remoting object via XML file?
Yes,
via machine.config and application level .config file (or web.config in
ASP.NET). Application-level XML settings take precedence over
machine.config.
16.
How can you automatically generate interface for the remotable
object in .NET with Microsoft tools?
Use
the Soapsuds tool.
----------------
1. What is datagrid? The DataGrid Web
server control is a powerful tool for displaying information from a data
source. It is easy to use; you can display editable data in a
professional-looking grid by setting only a few properties. At the same time,
the grid has a sophisticated object model that provides you with great
flexibility in how you display the data.
2. What’s the
difference between the System.Web.UI.WebControls.DataGrid
and and System.Windows.Forms.DataGrid? The Web UI
control does not inherently support master-detail data structures. As with
other Web server controls, it does not support two-way data binding. If you
want to update data, you must write code to do this yourself. You can only edit
one row at a time. It does not inherently support sorting, although it raises
events you can handle in order to sort the grid contents. You can bind the Web
Forms DataGrid to any object that supports the IEnumerable interface. The Web
Forms DataGrid control supports paging. It is easy to customize the appearance
and layout of the Web Forms DataGrid control as compared to the Windows Forms
one.
3. How do you
customize the column content inside the datagrid? If you want to customize the
content of a column, make the column a template column. Template columns work
like item templates in the DataList or Repeater control, except that you are
defining the layout of a column rather than a row.
4. How do you apply
specific formatting to the data inside the cells? You cannot specify
formatting for columns generated when the grid’s AutoGenerateColumns property
is set to true, only for bound or template columns. To format, set the column’s
DataFormatString property to a string-formatting expression suitable for the
data type of the data you are formatting.
5. How do you hide
the columns? One way to have columns appear dynamically is to create them at
design time, and then to hide or show them as needed. You can do this by
setting a column’s Visible property.
6. How do you display
an editable drop-down list? Displaying a drop-down list requires a template
column in the grid. Typically, the ItemTemplate contains a control such as a
data-bound Label control to show the current value of a field in the record.
You then add a drop-down list to the EditItemTemplate. In Visual Studio, you
can add a template column in the Property builder for the grid, and then use
standard template editing to remove the default TextBox control from the
EditItemTemplate and drag a DropDownList control into it instead.
Alternatively, you can add the template column in HTML view. After you have
created the template column with the drop-down list in it, there are two tasks.
The first is to populate the list. The second is to preselect the appropriate
item in the list — for example, if a book’s genre is set to “fiction,” when the
drop-down list displays, you often want “fiction” to be preselected.
7. How do you check
whether the row data has been changed? The definitive way to
determine whether a row has been dirtied is to handle the changed event for the
controls in a row. For example, if your grid row contains a TextBox control,
you can respond to the control’s TextChanged event. Similarly, for check boxes,
you can respond to a CheckedChanged event. In the handler for these events, you
maintain a list of the rows to be updated. Generally, the best strategy is to
track the primary keys of the affected rows. For example, you can maintain an
ArrayList object that contains the primary keys of the rows to update.
Here's a list of some
questions I use when interviewing .Net developers. It is not exhaustive, but
should give the interviewer an idea of the basic level of expertise an
individual has. If the interview is for a senior developer, these questions
should be followed by more in-depth questions that relate to the specific
projects (Web Services, SOA, XML, etc).
ASP.Net
Q. Explain the differences
between Server-side and Client-side code?
A. Server-side code executes on the server. Client-side code executes in the
context of the clients' browser.
Q. What are some ways to
manage state in an ASP.Net application?
A. Session objects, Application objects, ViewState, cookies, hidden form
fields.
Q. What does the
"EnableViewState" property do? Why would I want it on or off?
A. It allows page objects to save their state in a Base64 encoded string in the
page HTML. One should only have it enabled when needed because it adds to the
page size and can get fairly large for complex pages with many controls. (It
takes longer to download the page).
Q. What is the difference
between Server.Transfer and Response.Redirect? Why would I choose one over the
other?
A. Server.Transfer transfers excution directly to another page.
Response.Redirect sends a response to the client and directs the client (the
browser) to load the new page (it causes a roundtrip). If you don't need to
execute code on the client, Transfer is more efficient.
Q. How can I maintain Session
state in a Web Farm or Web Garden?
A. Use a State Server or SQL Server to store the session state.
Q. What base class do all Web
Forms inherit from?
A. The Page class.
Q. What does WSDL stand for?
What does it do?
A.(Web Services Description Language). It describes the interfaces and other
information of a web service.
Q. Which WebForm
Validator control would you use if you needed to make sure the values in two
different WebForm controls matched?
A. CompareValidator Control
Q. What property must you
set, and what method must you call in your code, in order to bind the data from
some data source to the Repeater control?
A. You must set the DataSource property and call the DataBind method.
C# Questions
Q. Can you explain what
inheritance is and an example of when you might use it?
A. Inheritance allows us to extend the functionality of a base class. It is an "Is
a" type of relationship rather than a "Uses" type of
relationship (a dalmation IS A dog which IS A canine which IS A mammal -
dalmations inherist from dog which inherits from canine which inherits from
mammal). All child classes retain the properties and methods of their parent
classes but may override them. When you want to inherit (use the functionality
of) another class. Base Class Employee. A Manager class could be derived from
the Employee base class.
Q. Does C# support
multiple-inheritance?
A. No, use interfaces instead.
Q. Can you prevent your class
from being inherited by another class?
A. Yes. The keyword “sealed” will prevent the class from being inherited.
Q. What does the keyword
“virtual” declare for a method or property?
A. The method or property can be overridden.
Q. What's the top .NET class
that everything is derived from?
A. System.Object.
Q. What does it mean that a
String is immutable?
A. Strings cannot be altered. When you alter a string (by adding to it for
example), you are actually creating a new string.
Q. If I have to alter a
string many times, such as mutliple concatenations, what class should I use?
A. StringBuilder. It is not immutable and is very efficient.
Q. In a Try - Catch - Finally
block, will the finally block execute if an exception has not occurred? If an
Exception has occurred?
A. Yes and yes.
Q. Whats MSIL, and why should
developers need an appreciation of it, if at all?
A. MSIL is the Microsoft Intermediate Language. All .NET compatible languages
will get converted to MSIL.
Q. Explain the three tier or
n-Tier model.
A. Presentation (UI), business (logic and underlying code) and data (from
storage or other sources).
Q. What is SOA?
A. Service Oriented Architecture. In SOA you create an abstract layer that your
applications use to access various "services" and can aggregate the
services. These services could be databases, web services, message queues or
other sources. The Service Layer provides a way to access these services that
the applications do not need to know how the access is done. For example, to
get a full customer record, I might need to get data from a SGL Server
database, a web service and a message queue. The Service layer hides this from
the calling application. All the application knows is that it asked for a full
customer record. It doesn't know what system or systems it came from or how it
was retrieved.
Q. What is the role of the
DataReader class in ADO.NET connections?
A. It returns a forward-only, read-only view of data from the data source when
the command is executed.
Q. Is XML case-sensitive?
A. Yes.
Q. What is the CLR?
A. Common Language Runtime
Q. Can you explain some
differences between an ADO.NET Dataset and an ADO Recordset? (Or describe some
features of a Dataset).
A. A DataSet can represent an entire relational database in memory, complete
with tables, relations, and views. A DataSet is designed to work without
any continuing connection to the original data source. Data in a DataSet
is bulk-loaded, rather than being loaded on demand. There's no concept of
cursor types in a DataSet. DataSets have no current record pointer You
can use For Each loops to move through the data. You can store many edits
in a DataSet, and write them to the original data source in a single operation.
Though the DataSet is universal, other objects in ADO.NET come in different
versions for different data sources
Q. Name some of the Microsoft
Application Blocks. Have you used any? Which ones?
A. Examples:
Exception Management
Logging
Data Access
User Interface
Caching Application Block for .NET
Asynchronous Invocation Application Block for .NET
Configuration Management Application Block for .NET
(there are others) We use Exception and Data Access
1.
What is the base class of .NET?
2.
Explain assemblies.
3.
Name some of the languages .NET support?
4.
ADO.NET features? Benefits? Drawbacks?
5.
How many types of exception handlers are there in .NET?
6.
Difference between Panel and GroupBox classes?
7.
What is the base class of Button control?
8.
What is Response object? How is it related to ASP’s Response
object?
9.
What is IIS? Have you used it?
10.
Main differences between ASP and ASP.NET.
more interview questions - all .NET and Web dev interview questions
18
Comments »
1. Main differences
between ASP and ASP.NET.
asp contains
scrips which are not compiled
where as in asp.net the code is compiled
Tech Interviews comment by Ashraf
2. 7.What is the base
class of Button control?
system.object
Tech Interviews comment by Ashraf
3. Some of the
languages that are supported by .NET
1. Visual Basic.NET
2. Visual C#
3. Visual C++
Tech Interviews comment by lakshmi
4. What is IIS? Have
you used it?
IIS - Internet Information Server
IIS is used to access the ASP.Net web applications
Yes, I used in ASP.NET web applications.
Tech Interviews comment by lakshmi
5. Main difference
between ASP and ASP.NET
ASP code will be interpretted
whereas the code written in ASP.NET will be
compiled.
Tech Interviews comment by lakshmi
6. ADO.NET features
1. Data will be retrieved through Datasets
2. Scalability
Tech Interviews comment by lakshmi
7. Explain assemblies
Assemblies are similar to dll files. Both has the
reusable pieces of code in the form of classes/ functions. Dll needs to be
registered but assemblies have its own metadata.
Tech Interviews comment by Kavitha Vijayaraghavan
8. Explain
Assemblies?
Assembly is a single deployable unit that contains information about the
implementation of classes, structures and interfaces. it also stores the
information about itself called metadata and includes name and verison of the
assembly, security information, information about the dependencies and the list
of files that constitute the assembly.
Assembly also contains namespaces. In the .Net
Framework, applications are deployed in the form of assemblies.
Tech Interviews comment by lakshmi
9. How many types of
exception handlers are there in .NET?
1. Unstructured Exception Handling
2. Strutured Exception Handling
Tech Interviews comment by lakshmi
10. ADO.NET features
1. Disconnected Data Architecture
2. Data cached in Datasets
3. Data transfer in XML format
4. Interaction with the database is done through data commands
Tech Interviews comment by lakshmi
11. What is the base
class of Button control?
Listing from visual studio .net > Button Class
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ButtonBase
System.Windows.Forms.Button
Tech Interviews comment by flupo
12. How many types of
exception handlers are there in .NET?
From
MSDN>> “How the Runtime Manages Exceptions”
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconexceptionsoverview.asp
The exception information table represents four
types of exception handlers for protected blocks:
A finally handler that executes whenever the block
exits, whether that occurs by normal control flow or by an unhandled exception.
A fault handler that must execute if an exception
occurs, but does not execute on completion of normal control flow.
A type-filtered handler that handles any exception
of a specified class or any of its derived classes.
A user-filtered handler that runs user-specified
code to determine whether the exception should be handled by the associated handler
or should be passed to the next protected block.
Tech Interviews comment by flupo
13. Difference between
Panel and GroupBox classes?
Panel is scrollable
Tech Interviews comment by flupo
14. Difference between
Panel and GroupBox classes?
Panel & Group box both can used as container for
other controls like radio buttons & check box.
the difference in panel & group box are
Panel
1) In case of panel captions cannot be displayed
2) Can have scroll bars.
Group box
1) Captions can be displayed.
2) Cannot have a scroll bar
Tech Interviews comment by Arun kumar Rachakonda
15. This article is
super, but any one can tell me how to face an interview, and good interview
questions in c# .net asp.net with answers please.
Tech Interviews comment by ramkiran
16. What are the
advantages and drawbacks of using ADO.NET?
Pros
====
ADO.NET is rich with plenty of features that are bound to impress even the most
skeptical of programmers. If this weren’t the case, Microsoft wouldn’t even be
able to get anyone to use the Beta. What we’ve done here is come up with a
short list of some of the more outstanding benefits to using the ADO.NET
architecture and the System.Data namespace.
* Performance – there is no doubt that ADO.NET is
extremely fast. The actual figures vary depending on who performed the test and
which benchmark was being used, but ADO.NET performs much, much faster at the
same tasks than its predecessor, ADO. Some of the reasons why ADO.NET is faster
than ADO are discussed in the ADO versus ADO.NET section later in this chapter.
* Optimized SQL Provider – in addition to performing
well under general circumstances, ADO.NET includes a SQL Server Data Provider
that is highly optimized for interaction with SQL Server. It uses SQL Server’s
own TDS (Tabular Data Stream) format for exchanging information. Without
question, your SQL Server 7 and above data access operations will run blazingly
fast utilizing this optimized Data Provider.
* XML Support (and Reliance) – everything you do in
ADO.NET at some point will boil down to the use of XML. In fact, many of the
classes in ADO.NET, such as the DataSet, are so intertwined with XML that they
simply cannot exist or function without utilizing the technology. You’ll see
later when we compare and contrast the “old” and the “new” why the reliance on
XML for internal storage provides many, many advantages, both to the framework
and to the programmer utilizing the class library.
* Disconnected Operation Model – the core ADO.NET
class, the DataSet, operates in an entirely disconnected fashion. This may be
new to some programmers, but it is a remarkably efficient and scalable
architecture. Because the disconnected model allows for the DataSet class to be
unaware of the origin of its data, an unlimited number of supported data
sources can be plugged into code without any hassle in the future.
* Rich Object Model – the entire ADO.NET
architecture is built on a hierarchy of class inheritance and interface
implementation. Once you start looking for things you need within this
namespace, you’ll find that the logical inheritance of features and base class
support makes the entire system extremely easy to use, and very customizable to
suit your own needs. It is just another example of how everything in the .NET
framework is pushing toward a trend of strong application design and strong OOP
implementations.
Cons
====
Hard as it may be to believe, there are a couple of drawbacks or disadvantages
to using the ADO.NET architecture. I’m sure others can find many more faults
than we list here, but we decided to stick with a short list of some of the
more obvious and important shortcomings of the technology.
* Managed-Only Access – for a few obvious reasons,
and some far more technical, you cannot utilize the ADO.NET architecture from
anything but managed code. This means that there is no COM interoperability
allowed for ADO.NET. Therefore, in order to take advantage of the advanced SQL
Server Data Provider and any other feature like DataSets, XML internal data
storage, etc, your code must be running under the CLR.
* Only Three Managed Data Providers (so far) –
unfortunately, if you need to access any data that requires a driver that
cannot be used through either an OLEDB provider or the SQL Server Data
Provider, then you may be out of luck. However, the good news is that the OLEDB
provider for ODBC is available for download from Microsoft. At that point the
down-side becomes one of performance, in which you are invoking multiple layers
of abstraction as well as crossing the COM InterOp gap, incurring some initial
overhead as well.
* Learning Curve – despite the misleading name,
ADO.NET is not simply a new version of ADO, nor should it even be considered a
direct successor. ADO.NET should be thought of more as the data access class
library for use with the .NET framework. The difficulty in learning to use
ADO.NET to its fullest is that a lot of it does seem familiar. It is this that
causes some common pitfalls. Programmers need to learn that even though some
syntax may appear the same, there is actually a considerable amount of
difference in the internal workings of many classes. For example (this will be
discussed in far more detail later), an ADO.NET DataSet is nothing at all like
a disconnected ADO RecordSet. Some may consider a learning curve a drawback,
but I consider learning curves more like scheduling issues. There’s a learning
curve in learning anything new; it’s just up to you to schedule that curve into
your time so that you can learn the new technology at a pace that fits your
schedule.
Source: http://www.vbip.com/books/1861005563/chapter_5563_06.asp
Tech Interviews comment by Rajaraaman Muralimanoharan
17. What is the use of
ErrorProvider Control?
Saddam
Tech Interviews comment by Saddam
18. Q) What are
assemblies ?
ANSWER
An assembly is a single deployable unit that
contains all the information about the implementation of :
- classes
- structures and
- interfaces
An assembly stores all the information about itself.
This information is called METADATA and include the name and the verison number
of the assembly, security information, information about the dependencies and a
lost of files that constitute the assembly.
All the application developed using the .NET
framework are made up of assemblies.
Namespaces are also stored in
assemblies
MS SQL Server
interview questions
This one
always gets asked. For a while the database interview questions were limited to
Oracle and generic database design questions. This is a set of more than a
hundred Microsoft SQL Server interview questions. Some questions are open-ended,
and some do not have answers.
1.
What is normalization? - Well a relational database is basically
composed of tables that contain related data. So the Process of organizing this
data into tables is actually referred to as normalization.
2.
What is a Stored
Procedure? - Its nothing but a set of T-SQL statements combined to perform
a single task of several tasks. Its basically like a Macro so when you invoke
the Stored procedure, you actually run a set of statements.
3.
Can you give an example of Stored Procedure? - sp_helpdb ,
sp_who2, sp_renamedb are a set of system defined stored procedures. We can also
have user defined stored procedures which can be called in similar way.
4.
What is a trigger? - Triggers are basically used to implement
business rules. Triggers is also similar to stored procedures. The difference
is that it can be activated when data is added or edited or deleted from a table
in a database.
5.
What is a view? - If we have several tables in a db and we want
to view only specific columns from specific tables we can go for views. It
would also suffice the needs of security some times allowing specfic users to
see only specific columns based on the permission that we can configure on the
view. Views also reduce the effort that is required for writing queries to
access specific columns every time.
6.
What is an Index? - When queries are run against a db, an index
on that db basically helps in the way the data is sorted to process the query
for faster and data retrievals are much faster when we have an index.
7.
What are the types of indexes available with SQL Server? - There
are basically two types of indexes that we use with the SQL Server. Clustered and
the Non-Clustered.
8.
What is the basic difference between clustered
and a non-clustered index? - The difference is that, Clustered index is
unique for any given table and we can have only one clustered index on a table.
The leaf level of a clustered index is the actual data and the data is resorted
in case of clustered index. Whereas in case of non-clustered index the leaf
level is actually a pointer to the data in rows so we can have as many
non-clustered indexes as we can on the db.
9.
What are cursors? - Well cursors help us to do an operation on a
set of data that we retreive by commands such as Select columns from table. For
example : If we have duplicate records in a table we can remove it by declaring
a cursor which would check the records during retreival one by one and remove
rows which have duplicate values.
10.
When do we use the UPDATE_STATISTICS command? - This command is
basically used when we do a large processing of data. If we do a large amount
of deletions any modification or Bulk Copy into the tables, we need to
basically update the indexes to take these changes into account. UPDATE_STATISTICS
updates the indexes on these tables accordingly.
11.
Which TCP/IP port does SQL Server run on? - SQL Server runs on
port 1433 but we can also change it for better security.
12.
From where can you change the default port? - From the Network
Utility TCP/IP properties –> Port number.both on client and the server.
13.
Can you tell me the difference between DELETE & TRUNCATE
commands? - Delete command removes the rows from a table based on the condition
that we provide with a WHERE clause. Truncate will actually remove all the rows
from a table and there will be no data in the table after we run the truncate
command.
14.
Can we use Truncate command on a table which is referenced by
FOREIGN KEY? - No. We cannot use Truncate command on a table with Foreign Key
because of referential integrity.
15.
What is the use of DBCC commands? - DBCC stands for database
consistency checker. We use these commands to check the consistency of the
databases, i.e., maintenance, validation task and status checks.
16.
Can you give me some DBCC command options?(Database consistency
check) - DBCC CHECKDB - Ensures that tables in the db and the indexes are
correctly linked.and DBCC CHECKALLOC - To check that all pages in a db are
correctly allocated. DBCC SQLPERF - It gives report on current usage of transaction
log in percentage. DBCC CHECKFILEGROUP - Checks all tables file group for any
damage.
17.
What command do we use to rename a db? - sp_renamedb ‘oldname’ ,
‘newname’
18.
Well sometimes sp_reanmedb may not work you know because if some
one is using the db it will not accept this command so what do you think you
can do in such cases? - In such cases we can first bring to db to single user
using sp_dboptions and then we can rename that db and then we can rerun the
sp_dboptions command to remove the single user mode.
19.
What is the difference between a HAVING CLAUSE and a WHERE
CLAUSE? - Having Clause is basically used only with the GROUP BY function in a
query. WHERE Clause is applied to each row before they are part of the GROUP BY
function in a query.
20.
What do you mean by COLLATION? - Collation is basically the sort
order. There are three types of sort order Dictionary case sensitive, Dictonary
- case insensitive and Binary.
21.
What is a Join in SQL Server? - Join actually puts data from two
or more tables into a single result set.
22.
Can you explain the types of Joins that we can have with Sql
Server? - There are three types of joins: Inner Join, Outer Join, Cross Join
23.
When do you use SQL
Profiler? - SQL Profiler utility allows us to basically track connections
to the SQL Server and also determine activities such as which SQL Scripts are
running, failed jobs etc..
24.
What is a Linked
Server? - Linked Servers is a concept in SQL Server by which we can add
other SQL Server to a Group and query both the SQL Server dbs using T-SQL
Statements.
25.
Can you link only other SQL Servers or any database servers such
as Oracle? - We can link any server provided we have the OLE-DB provider from
Microsoft to allow a link. For Oracle we have a OLE-DB provider for oracle that
microsoft provides to add it as a linked server to the sql server group.
26.
Which stored procedure will you be running to add a linked
server? - sp_addlinkedserver,
sp_addlinkedsrvlogin
27.
What are the OS services that the SQL Server installation adds?
- MS SQL SERVER SERVICE, SQL AGENT SERVICE, DTC (Distribution transac
co-ordinator)
28.
Can you explain the role of each service? - SQL SERVER - is for
running the databases SQL AGENT - is for automation such as Jobs, DB
Maintanance, Backups DTC - Is for linking and connecting to other SQL Servers
29.
How do you troubleshoot SQL Server if its running very slow? -
First check the processor and memory usage to see that processor is not above
80% utilization and memory not above 40-45% utilization then check the disk
utilization using Performance Monitor, Secondly, use SQL Profiler to check for
the users and current SQL activities and jobs running which might be a problem.
Third would be to run UPDATE_STATISTICS command to update the indexes
30.
Lets say due to N/W or Security issues client is not able to
connect to server or vice versa. How do you troubleshoot? - First I will look
to ensure that port settings are proper on server and client Network utility
for connections. ODBC is properly configured at client end for connection
——Makepipe & readpipe are utilities to check for connection. Makepipe is
run on Server and readpipe on client to check for any connection issues.
31.
What are the authentication modes in SQL Server? - Windows mode
and mixed mode (SQL & Windows).
32.
Where do you think the users names and passwords will be stored
in sql server? - They get stored in master db in the sysxlogins table.
33.
What is log shipping? Can we do logshipping with SQL Server 7.0
- Logshipping is a new feature of SQL Server 2000. We should have two SQL
Server - Enterprise Editions. From Enterprise Manager we can configure the
logshipping. In logshipping the transactional log file from one server is
automatically updated into the backup database on the other server. If one
server fails, the other server will have the same db and we can use this as the
DR (disaster recovery) plan.
34.
Let us say the SQL Server crashed and you are rebuilding the
databases including the master database what procedure to you follow? - For
restoring the master db we have to stop the SQL Server first and then from
command line we can type SQLSERVER –m which will basically bring it into the
maintenance mode after which we can restore the master db.
35.
Let us say master db itself has no backup. Now you have to
rebuild the db so what kind of action do you take? - (I am not sure- but I
think we have a command to do it).
36.
What is BCP? When do we use it? - BulkCopy is a tool used to
copy huge amount of data from tables and views. But it won’t copy the
structures of the same.
37.
What should we do to copy the tables, schema and views from one
SQL Server to another? - We have to write some DTS packages for it.
38.
What are the different types of joins and what dies each do?
39.
What are the four main query statements?
40.
What is a sub-query? When would you use one?
41.
What is a NOLOCK?
42.
What are three SQL keywords used to change or set someone’s
permissions?
43.
What is the difference between HAVING clause and the WHERE
clause?
44.
What is referential integrity? What are the advantages of it?
45.
What is database normalization?
46.
Which command using Query Analyzer will give you the version of
SQL server and operating system?
47.
Using query analyzer, name 3 ways you can get an accurate count
of the number of records in a table?
48.
What is the purpose of using COLLATE in a query?
49.
What is a trigger?
50.
What is one of the first things you would do to increase
performance of a query? For example, a boss tells you that “a query that ran
yesterday took 30 seconds, but today it takes 6 minutes”
51.
What is an execution plan? When would you use it? How would you
view the execution plan?
52.
What is the STUFF function and how does it differ from the
REPLACE function?
53.
What does it mean to have quoted_identifier on? What are the
implications of having it off?
54.
What are the different types of replication? How are they used?
55.
What is the difference between a local and a global variable?
56.
What is the difference between a Local temporary table and a
Global temporary table? How is each one used?
57.
What are cursors? Name four types of cursors and when each one
would be applied?
58.
What is the purpose of UPDATE STATISTICS?
59.
How do you use DBCC statements to monitor various aspects of a
SQL server installation?
60.
How do you load large data to the SQL server database?
61.
How do you check the performance of a query and how do you
optimize it?
62.
How do SQL server 2000 and XML linked? Can XML be used to access
data?
63.
What is SQL server agent?
64.
What is referential integrity and how is it achieved?
65.
What is indexing?
66.
What is normalization and what are the different forms of
normalizations?
67.
Difference between server.transfer and server.execute method?
68.
What id de-normalization and when do you do it?
69.
What is better - 2nd Normal form or 3rd normal form? Why?
70.
Can we rewrite subqueries into simple select statements or with
joins? Example?
71.
What is a function? Give some example?
72.
What is a stored procedure?
73.
Difference between Function and Procedure-in general?
74.
Difference between Function and Stored Procedure?
75.
Can a stored procedure call another stored procedure. If yes
what level and can it be controlled?
76.
Can a stored procedure call itself(recursive). If yes what level
and can it be controlled.?
77.
How do you find the number of rows in a table?
78.
Difference between Cluster and Non-cluster index?
79.
What is a table called, if it does not have neither Cluster nor Non-cluster
Index?
80.
Explain DBMS, RDBMS?
81.
Explain basic SQL queries with SELECT from where Order By, Group
By-Having?
82.
Explain the basic concepts of SQL server architecture?
83.
Explain couple pf features of SQL server
84.
Scalability, Availability, Integration with internet, etc.)?
85.
Explain fundamentals of Data ware housing & OLAP?
86.
Explain the new features of SQL server 2000?
87.
How do we upgrade from SQL Server 6.5 to 7.0 and 7.0 to 2000?
88.
What is data integrity? Explain constraints?
89.
Explain some DBCC commands?
90.
Explain sp_configure commands, set commands?
91.
Explain what are db_options used for?
92.
What is the basic functions for master, msdb, tempdb databases?
93.
What is a job?
94.
What are tasks?
95.
What are primary keys and foreign keys?
96.
How would you Update the rows which are divisible by 10, given a
set of numbers in column?
97.
If a stored procedure is taking a table data type, how it looks?
98.
How m-m relationships are implemented?
99.
How do you know which index a table is using?
100.
How will oyu test the stored procedure taking two parameters
namely first name and last name returning full name?
101.
How do you find the error, how can you know the number of rows
effected by last SQL statement?
102.
How can you get @@error and @@rowcount at the same time?
103.
What are sub-queries? Give example? In which case sub-queries
are not feasible?
104.
What are the type of joins? When do we use Outer and Self joins?
105.
Which virtual table does a trigger use?
106.
How do you measure the performance of a stored procedure?
107.
Questions regarding Raiseerror?
108.
Questions on identity?
109.
If there is failure during updation of certain rows, what will
be the state?
Tough ASP.NET
interview questions
1.
Describe the difference between a Thread and a Process?
2.
What is a Windows Service and how does its lifecycle differ from
a “standard” EXE?
3.
What is the maximum amount of memory any single process on
Windows can address? Is this different than the maximum virtual memory for the
system? How would this affect a system design?
4.
What is the difference between an EXE and a DLL?
5.
What is strong-typing versus weak-typing? Which is preferred?
Why?
6.
What’s wrong with a line like this? DateTime.Parse(myString
7.
What are PDBs? Where must they be located for debugging to work?
8.
What is cyclomatic complexity and why is it important?
9.
Write a standard lock() plus double check to create a critical
section around a variable access.
10.
What is FullTrust? Do GAC’ed assemblies have FullTrust?
11.
What benefit does your code receive if you decorate it with
attributes demanding specific Security permissions?
12.
What does this do? gacutil /l | find /i “about”
13.
What does this do? sn -t foo.dll
14.
What ports must be open for DCOM over a firewall? What is the
purpose of Port 135?
15.
Contrast OOP and SOA. What are tenets of each
16.
How does the XmlSerializer work? What ACL permissions does a
process using it require?
17.
Why is catch(Exception) almost always a bad idea?
18.
What is the difference between Debug.Write and Trace.Write? When
should each be used?
19.
What is the difference between a Debug and Release build? Is
there a significant speed difference? Why or why not?
20.
Does JITting occur per-assembly or per-method? How does this
affect the working set?
21.
Contrast the use of an abstract base class against an interface?
22.
What is the difference between a.Equals(b) and a == b?
23.
In the context of a comparison, what is object identity versus
object equivalence?
24.
How would one do a deep copy in .NET?
25.
Explain current thinking around IClonable.
26.
What is boxing?
27.
Is string a value type or a reference type?
Visit Scott
Hanselman’s blog for more ASP.NET interview questions he asks.
more interview questions - all .NET and Web dev interview questions
16
Comments »
1. Ans2)
ASHX files contain HTTP handlers.
HTTP Handlers are nothing but software modules that handle raw HTTP requests
received by ASP.NET
With .ASHX files one can easily deploy HTTP Handlers without modifying IIS
metabase.
Tech Interviews comment by raj kiran jampa
2. 13.What is a
Windows Service and how does its lifecycle differ from a “standard” EXE?
Windows Service applications are long-running
applications that are ideal for use in server environments. The applications do
not have a user interface or produce any visual output; it is instead used by
other programs or the system to perform operations. Any user messages are
typically written to the Windows Event Log. Services can be automatically
started when the computer is booted. This makes services ideal for use on a
server or whenever you need long-running functionality that does not interfere
with other users who are working on the same computer. They do not require a
logged in user in order to execute and can run under the context of any user
including the system. Windows Services are controlled through the Service Control
Manager where they can be stopped, paused, and started as needed.
How does the lifecycle of Windows services differ
from Standard EXE?
Windows services lifecycle is managed by “Service
Control Manager” which is responsible for starting and stopping the service and
the applications do not have a user interface or produce any visual output, but
“Standard executable” doesn’t require Control Manager and is directly related
to the visual output
Tech Interviews comment by Anu
3. 33. What is the
difference between a.Equals(b) and a == b?
a=b is used for assigning the values (rather then comparison) and a==b is for
comparison.
Tech Interviews comment by Rakshit R Pitalia
4. difference between
thread and process?
Thread - is used to execute more than one program at
a time.
process - executes single program
Tech Interviews comment by lakshmi
5. What is the
difference between a.Equals(b) and a == b?
a == b is used to compare the references of two
objects
a.Equals(b) is used to compare two objects
Tech Interviews comment by Nirmalya
6. string is actually
ref Type but some difference with other ref object
Tech Interviews comment by X
7. Boxing:
Convertion of value type to ref type
Tech Interviews comment by X
8. IClonable
interface is used to clone objects like constructor copy in c++
Tech Interviews comment by X
9. Q1 - o A thread is
a path of execution that run on CPU, a proccess is a collection of threads that
share the same virtual memory. A process have at least one thread of execution,
and a thread always run in a process context.
Q5 - Strong type is checking the types of variables
as soon as possible, usually at compile time. While weak typing is delaying
checking the types of the system as late as possible, usually to run-time.
Which is preferred depends on what you want. For scripts & quick stuff
you’ll usually want weak typing, because you want to write as much less (is
this a correct way to use Ensligh?) code as possible. In big programs, strong
typing can reduce errors at compile time.
Q7 - To debug precompiled components such as
business objects and code-behind modules, you need to generate debug symbols.
To do this, compile the components with the debug flags by using either Visual
Studio .NET or a command line compiler such as Csc.exe (for Microsoft Visual C#
.NET) or Vbc.exe (for Microsoft Visual Visual Basic .NET).
Using Visual Studio .NET1. Open the ASP.NET Web
Application project in Visual Studio .NET.
2. Right-click the project in the Solution Explorer and click Properties.
3. In the Properties dialog box, click the Configuration Properties folder.
4. In the left pane, select Build.
5. Set Generate Debugging Information to true.
6. Close the Properties dialog box.
7. Right-click the project and click Build to compile the project and generate
symbols (.pdb files).
Q10 - Your code is allowed to do anything in the
framework, meaning that all (.Net) permissions are granted. The GAC has
FullTrust because it’s on the local HD, and that has FullTrust by default, you
can change that using caspol
Q17 - Well, if at that point you know that an error
has occurred, then why not write the proper code to handle that error instead
of passing a new Exception object to the catch block? Throwing your own
exceptions signifies some design flaws in the project.
Q18 - The Debug.Write call won’t be compiled when
the DEBUG symbol is not defined (when doing a release build). Trace.Write calls
will be compiled. Debug.Write is for information you want only in debug builds,
Trace.Write is for when you want it in release build as well. And in any case,
you should use something like log4net because that is both faster and better
Q19 - Debug build contain debug symbols and can be
debugged while release build doesn’t contain debug symbols, doesn’t have
[Contional(”DEBUG”)] methods calls compiled, can’t be debugged (easily, that
is), less checking, etc. There should be a speed difference, because of
disabling debug methods, reducing code size etc but that is not a guarantee (at
least not a significant one)
Q21 - In the interface all methods must be abstract,
in the abstract class some methods can be concrete. In the interface no
accessibility modifiers are allowed, which is ok in abstract classes
Q22 - a equals b -> copies contents of b to a
a == b -> checks if a is equal to b
Q24 - System.Array.CopyTo() - Deep copies an Array
Q26 - Boxing is an implicit conversion of a value
type to the type object
int i = 123; // A value type
Object box = i // Boxing
Unboxing is an explicit conversion from the type object to a value type
int i = 123; // A value type
object box = i; // Boxing
int j = (int)box; // Unboxing
Q27 - String is Reference Type.
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte,
short,strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap
Tech Interviews comment by Harish
10. What’s wrong with
a line like this? DateTime.Parse(myString)
the result returned by this function is not assigned
to anything, should be something like
varx = DateTime.Parse(myString)
Tech Interviews comment by flupo
11. Q4. An EXE can run
independently, whereas DLL will run within an EXE. DLL is an in-process file
and EXE is an out-process file
Tech Interviews comment by Devapriya
12. What is the
difference between a.Equals(b) and a == b?
Equals method compares both type and value of the
variable, while == compares value.
int a = 0;
bool b = 0
if(a.Equals(b))
Tech Interviews comment by flupo
13. Q 12 What does
this do? gacutil /l | find /i “about
This command is used to install strong typed assembly in GAC
Tech Interviews comment by raksha
14. Q14) Contrast OOP
and SOA. What are tenets of each
A. Service Oriented Architecture. In SOA you create an abstract layer that your
applications use to access various “services” and can aggregate the services.
These services could be databases, web services, message queues or other
sources. The Service Layer provides a way to access these services that the
applications do not need to know how the access is done. For example, to get a
full customer record, I might need to get data from a SGL Server database, a
web service and a message queue. The Service layer hides this from the calling
application. All the application knows is that it asked for a full customer
record. It doesn’t know what system or systems it came from or how it was
retrieved.
Tech Interviews comment by raksha
15. 8.) Cyclomatic
complexity is a computer science metric (measurement) developed by Thomas
McCabe used to generally measure the complexity of a program. It directly
measures the number of linearly independent paths through a program’s source
code.
The concept, although not the method, is somewhat
similiar to that of general text complexity measured by the Flesch-Kincaid
Readability Test.
Cyclomatic complexity is computed using a graph that
describes the control flow of the program. The nodes of the graph correspond to
the commands of a program. A directed edge connects two nodes, if the second
command might be executed immediately after the first command. By definition,
CC = E - N + P
where
CC = cyclomatic complexity
E = the number of edges of the graph
N = the number of nodes of the graph
P = the number of connected components.
[1]
Tech Interviews comment by Marc
16.
Here is very nice definition of Process vs. Thread:
“Process is unit of allocation while Thread is unit of execution. Each process
has one or more threads. Each thread belong to one process”
A reader
recently interviewed for C# position at Wipro and sent the following questions:
1. Difference between
directcast and ctype.
2. An example of a
ctype and directcast.
3. ctype(123.34,integer)
- should it throw an error? Why or why not?
4. directcast(123.34,integer)
- should it throw an error? Why or why not?
5. Difference between
a sub and a function.
6. Explain manifest
& metadata.
7. Scope of
public/private/friend/protected/protected friend.
8. Different kinds of
methods.
9. Difference between
imperative and interrogative code.
10. Difference between
value and reference type.
11. What are the two
kinds of properties.
12. What is the raise
event used for?
13. Explain
constructor.
14. What is a
resource? Provide an example from your recent project.
15. What is a system
lock?
16. Describe ways of
cleaning up objects.
17. Where does the
dispose method lie and how can it be used to clean up resources?
18. How can you clean
up objects holding resources from within the code?
Do you
have a job interview with Wipro? Read
what others had to say.
more interview questions - all .NET interview questions
16
Comments »
1. Why is a c#
position getting asked VB.NET questions? Are they playing a trick on this
person?
Tech Interviews comment by Deric Cheng
2. Ans 1)
DirectCast requires the run-time type of an object variable to bethe same as
the specified type.The run-time performance ofDirectCast is better than that of
CType, if the specified type and the run-time typeof the expression are the
same.
Ctype works fine if there is a valid conversion defined between the expression
and the type.
Tech Interviews comment by raj kiran jampa
3. Ans3) It would
work fine. As the runtime type of 123.34 would be double, and Double can be
converted to Integer.
Ans4) It would throw an InvalidCast exception as the runtime type of 123.34
(double) doesnt match with Integer.
Tech Interviews comment by raj kiran jampa
4. Ans 18) Call the
dispose method from code for clean up of objects
Tech Interviews comment by Tkum
5. Ans 5) A Sub does not
return anything whereas a Function returns something.
Tech Interviews comment by Prashanth Gajra
6. Ans 5)
-A Sub Procedure is a method will not return a value
-A sub procedure will be defined with a “Sub” keyword
Sub ShowName(ByVal myName As String)
Console.WriteLine(”My name is: ” & myName)
End Sub
-A function is a method that will return value(s).
-A function will be defined with a “Function” keyword
Function FindSum(ByVal num1 As Integer, ByVal num2
As Integer) As Integer
Dim sum As Integer = num1 + num2
Return sum
End Function
Tech Interviews comment by Yatish
7. Difference between
imperative and interrogative code. in .net
Tech Interviews comment by kirankumar
8. What are the two
kinds of properties .net
Tech Interviews comment by kirankumar
9. Where does the
dispose method lie and how can it be used to clean up resources in .net
Tech Interviews comment by kirankumar
10. Difference between
a sub and a function. in .net
Tech Interviews comment by kirankumar
11. 6. Manifest is
metadata about assemblies. Metadata is machine-readable information about a
resource, or “”data about data.” In .NET, metadata includes type definitions,
version information, external assembly references, and other standardized
information.
9. There are imperative and interrogative functions
and I think they are talking about that. Imperative functions are the one which
return a value while the interrogative functions do not return a value.
11. Two types of properties in .Net: Get & Set
12. Raise events are well explained herer: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmRaiseEvent.asp
13. Constructor is a method in the class which has
the same name as the class (in VB.Net its New()). It initialises the member
attributes whenever an instance of the class is created.
Tech Interviews comment by Rajeev Ranjan
12. 16.Describe ways
of cleaning up objects
There is a perfect tool provide by .net frameworks
calles Garbage collector, where by mean
of GC we can clean up the object and reclaim the memory.The namespace used is
System.GC
Tech Interviews comment by madhu
13. Scope of
public/private/friend/protected/protected friend.
Visual Basic/Visual C#
Public/public All members in all classes and
projects.
Private/private Members of the current class only.
Friend/internal All members in the current project.
Protected/protected All members in the current class
and in classes derived from this member’s class. Can be used only in member
definitions, not for class or module definitions.
Protected Friend/protected internal All members in
the current project and all members in classes derived from this member’s
class. Can be used only in member definitions, not for class or module
definitions.
Tech Interviews comment by Rakshit R Pitalia
14. 6. Explain
Manifest and Metadata?
Manifest: Manifest describes assembly itself.
Assembly Name, version number, culture, strong name, list of all files, Type
references, and referenced assemblies.
Metadata: Metadata describes contents in an assembly classes, interfaces,
enums, structs, etc., and their containing namespaces, the name of each type,
its visibility/scope, its base class, the nterfaces it implemented, its methods
and their scope, and each method’s parameters, type’s properties, and so on.
10. what are value types and reference types?
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte,
short, strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap
Tech Interviews comment by Harish
15. ans 16) the run
time will maintain a service called as garbage collector.this service will take
care of deallocating memory corresponding to objects.it works as a thread with
least priority.when application demenads for memory the runtime will take care
of setting the high priority for the garbage collector,so that it will be
called for execution and memory will be released.the programmer can make a call
to garbage colector by using GC class in ststem name space.
Tech Interviews comment by santosh vijaykumar
16. 1.Which controls
do not have events?
Ans:Timer control.
2.What is the maximum size of the textbox?
Ans:65536.
3.Which property of the textbox cannot be changed at
runtime?
Ans:Locked Porperty.
4.Which control cannot be placed in MDI?
Ans:The controls that do not have events.
Tech Interviews comment by Karthika Mohan
A reader sent in the list
of open-ended .NET interview questions.
1.
What is the difference between VB 6 and VB.NET?
2.
What are the authentication methods in .NET?
3.
What’s the use of formatters in .NET?
4.
What is Serialization in .NET?
5.
How is Threading done in .NET?
6.
Differences between Namespace, Class, Assembly?
7.
What’s the use of System.Diagnostics.Process class?
more interview questions - all VB and .NET interview questions
13
Comments »
1. Answer for Ques #7.
Provides access to local and remote processes and enables you to start and stop
local system processes.
Tech Interviews comment by Rafiq
2. Difference between
VB6 and VB.Net
vb.net
1. VB.net is object oriented
2. VB.Net can be used in Managed Code
3. It supports inheritance, implements
Tech Interviews comment by T.Sriniwas
3. Difference between
VB6 and VB.Net
vb.net
1. VB.net is object oriented
2. VB.Net can be used in Managed Code
3. It supports inheritance, implements
Tech Interviews comment by T.Sriniwas
4. i want interview
questions in dot net techonolgy
Tech Interviews comment by sathya
5. hi
this is good information for the programmers and the persons who are looking
for jobs.
Tech Interviews comment by rishabh mishra
6. Differences
between VB and VB.net
VB
_________________________________________
1,Object-based Language
2,Doesnot support Threading
3,Not powerful Exception handling
mechanism
4,Doesnot having support for the
console based applications
5,Cannot use more than one version
of com objects in vb application
called DLL error
6,Doesnot support for the Disconnected
data source.
VB.Net
__________________________
1,Object-oriented Language
2,supports Threading
3,powerful Exception handling
mechanism
4,having support for the
console based applications
5,More than one version of
dll is supported
6,supports the Disconnected
data source by using Dataset class
Tech Interviews comment by shreecanth
7. What is
Serialization in .NET?
The serialization is the process of converting the
objects into stream of bytes.
they or used for transport the objects(via remoting) and persist objects(via
files and databases)
Tech Interviews comment by madhu
8. What is use of
System.Diagnostics.Process class?
By using System.Diagnostics.Process class, we can
provide access to the files which are presented in the local and remote system.
Example:
System.Diagnostics.Process(”c:\mlaks\example.txt”) — local file
System.Diagnostics.Process(”http://www.mlaks.com\example.txt”) — remote file
Tech Interviews comment by lakshmi
9. difference between
VB6 and VB.NET
VB:
1. Object-based language
2. Does not support inheritance
3. ADO.Net does not give support for disconnected data architecture
4. No interoperability function
5. No support for threading
VB.Net
1. Object-Oriented Programming lanugage
2. ADO.Net gives support for disconnected data architecture
3. It provides interoperability
4. It uses managed code
5. supports threading
6. provides access to third-party controls like COM, DCOM
Tech Interviews comment by lakshmi
10. what are the
authentication methods in .NET?
Ans:
1. Windows: Basic, digest or Integrated windows authentication
2. Microsoft passport Authentication
3. Forms Authentication
4. Client Certificate Authentication
Tech Interviews comment by lakshmi
11. Dear Provider,
Thanx a lot for such a helpful techinterview
questions with andwers which helps everyone to get rid of books.
Regards,
Mitul.
Tech Interviews comment by Mitul
12. Dear Tech,
this is sriram. one suggestion that, why cont you add some info/questions about
infragitics related to .NET,Java,.. Because this is one of the requirements in
companies…
If you do so.. I will be thank full and all others may get gained to this… Even
many of the members dont know about this.. And they will get known to this.. If
you do so…
OK
Thanking you,
-sriram
Tech Interviews comment by sriram
13.
What is the difference between VB 6 and VB.NET?
1.The concept of the complete flow of execution of a program from start to
finish: Visual Basic
hides this aspect of programs from you, so that the only elements of a Visual
Basic program you
code are the event handlers and any methods in class modules. C# makes the
complete program
available to you as source code. The reason for this has to do with the fact
that C# can be seen,
philosophically, as next-generation C++. The roots of C++ go back to the 1960s
and predate windowed
user interfaces and sophisticated operating systems. C++ evolved as a
low-level, closeto-
the-machine, all-purpose language. To write GUI applications with C++ meant
that you had
to invoke the system calls to create and interact with the windowed forms. C#
has been
designed to build on this tradition while simplifying and modernizing C++, to
combine the
low-level performance benefits of C++ with the ease of coding in Visual Basic.
Visual Basic, on
the other hand, is designed specifically for rapid application development of
Windows GUI
applications. For this reason, in Visual Basic all the GUI boilerplate code is
hidden, and all the
Visual Basic programmer implements are the event handlers. In C# on the other
hand, this boilerplate
code is exposed as part of your source code.
2. Classes and inheritance: C# is a genuine object-oriented language, unlike
Visual Basic, requiring
all code to be a part of a class. It also includes extensive support for
implementation inheritance.
Indeed, most well-designed C# programs will be very much designed around this
form of
inheritance, which is completely absent in Visual Basic.
1.
Explain the .NET architecture.
2.
How many languages .NET is supporting now? - When .NET was
introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The
site DotNetLanguages.Net says 44 languages are
supported.
3.
How is .NET able to support multiple languages? - a language
should comply with the Common Language Runtime standard to become a .NET
language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL
for short). This is called as Managed Code. This Managed code is run in .NET
environment. So after compilation to this IL the language is not a barrier. A
code can call or use a function written in another language.
4.
How ASP .NET different from ASP? - Scripting is separated
from the HTML, Code is compiled as a DLL, these DLLs can be executed on the
server.
5.
Resource Files: How to use the resource files, how to know which
language to use?
6.
What is smart navigation? - The cursor position is
maintained when the page gets refreshed due to the server side validation and
the page gets refreshed.
7.
What is view state? - The web is stateless. But in ASP.NET, the
state of a page is maintained in the in the page itself automatically. How? The
values are encrypted and saved in hidden controls. this is done automatically
by the ASP.NET. This can be switched off / on for a single control
8.
Explain the life cycle of an ASP .NET page.
9.
How do you validate the controls in an ASP .NET page? - Using special validation
controls that are meant for this. We have Range Validator, Email Validator.
10.
Can the validation be done in the server side? Or this can be
done only in the Client side? - Client side is done by default. Server side
validation is also possible. We can switch off the client side and server side
can be done.
11.
How to manage pagination in a page? - Using pagination option in
DataGrid control. We have to set the number of records for a page, then it
takes care of pagination by itself.
12.
What is ADO .NET and what is difference between ADO and ADO.NET? - ADO.NET is
stateless mechanism. I can treat the ADO.Net as a separate in-memory database
where in I can use relationships between the tables and select insert and
updates to the database. I can update the actual database as a batch.
more interview questions - all .NET and Web dev interview questions
8
Comments »
1. I want a detailed
answer for the question.
1)Explain the life cycle of an ASP .NET page.
2)Explain the .NET architecture.
Tech Interviews comment by Avinash GJ
2. When a page
request is sent to the Web server, whether through a submission or location
change, the page is run through a series of events during its creation and
disposal. When we try to build ASP.NET pages and this execution cycle is not
taken into account, we can cause a lot of headaches for ourselves. However,
when used and manipulated correctly, a page’s execution cycle can be an
effective and powerful tool. Many developers are realizing that understanding
what happens and when it happens is crucial to effectively writing ASP.NET
pages or user controls. So let’s examine in detail the ten events of an ASP.NET
page, from creation to disposal. We will also see how to tap into these events
to implant our own custom code.
I’ll set the stage with a simple submission form
written in ASP.NET with C#. The page is loaded for the first time and has
several server-side Web controls on it. When the Web server receives a request
for the page, it will process our Web controls and we will eventually get
rendered HTML. The first step in processing our page is object initialization.
Download source code
View demo
1. Object Initialization
A page’s controls (and the page itself) are first
initialized in their raw form. By declaring your objects within the constructor
of your C# code-behind file (see Figure 1), the page knows what types of
objects and how many to create. Once you have declared your objects within your
constructor, you may then access them from any sub class, method, event, or
property. However, if any of your objects are controls specified within your
ASPX file, at this point the controls have no attributes or properties. It is
dangerous to access them through code, as there is no guarantee of what order
the control instances will be created (if they are created at all). The
initialization event can be overridden using the OnInit method.
Figure 1 - Controls are initialized based on their
declaration.
2. Load Viewstate Data
After the Init event, controls can be referenced
using their IDs only (no DOM is established yet for relative references). At
LoadViewState event, the initialized controls receive their first properties:
viewstate information that was persisted back to the server on the last
submission. The page viewstate is managed by ASP.NET and is used to persist
information over a page roundtrip to the server. Viewstate information is saved
as a string of name/value pairs and contains information such as control text
or value. The viewstate is held in the value property of a hidden control that
is passed from page request to page request. As you can see, this is a giant
leap forward from the old ASP 3.0 techniques of maintaining state. This event can
be overridden using the LoadViewState method and is commonly used to customize
the data received by the control at the time it is populated. Figure 2 shows an
example of overriding and setting viewstate at the LoadViewState event.
Figure 2 - When LoadViewState is fired, controls are
populated with the appropriate viewstate data.
3. LoadPostData Processes Postback Data
During this phase of the page creation, form data
that was posted to the server (termed postback data in ASP.NET) is processed
against each control that requires it. When a page submits a form, the
framework will implement the IPostBackDataHandler interface on each control
that submitted data. The page then fires the LoadPostData event and parses
through the page to find each control that implements this interface and
updates the control state with the correct postback data. ASP.NET updates the
correct control by matching the control’s unique ID with the name/value pair in
the NameValueCollection. This is one reason that ASP.NET requires unique IDs
for each control on any given page. Extra steps are taken by the framework to
ensure each ID is unique in situations, such as several custom user controls
existing on a single page. After the LoadPostData event triggers, the
RaisePostDataChanged event is free to execute (see below).
4. Object Load
Objects take true form during the Load event. All
object are first arranged in the page DOM (called the Control Tree in ASP.NET)
and can be referenced easily through code or relative position (crawling the
DOM). Objects are then free to retrieve the client-side properties set in the
HTML, such as width, value, or visibility. During Load, coded logic, such as
arithmetic, setting control properties programmatically, and using the
StringBuilder to assemble a string for output, is also executed. This stage is
where the majority of work happens. The Load event can be overridden by calling
OnLoad as shown in Figure 3.
Figure 3 - The OnLoad event is an ideal location to
place logic.
5. Raise PostBack Change Events
As stated earlier, this occurs after all controls
that implement the IPostBackDataHandler interface have been updated with the
correct postback data. During this operation, each control is flagged with a Boolean
on whether its data was actually changed or remains the same since the previous
submit. ASP.NET then sweeps through the page looking for flags indicating that
any object’s data has been updated and fires RaisePostDataChanged. The
RaisePostDataChanged event does not fire until all controls are updated and
after the Load event has occurred. This ensures data in another control is not
manually altered during the RaisePostDataChanged event before it is updated
with postback data.
6. Process Client-Side PostBack Event
After the server-side events fire on data that was
changed due to postback updates, the object which caused the postback is
handled at the RaisePostBackEvent event. The offending object is usually a
control that posted the page back to the server due to a state change (with
autopostback enabled) or a form submit button that was clicked. There is often
code that will execute in this event, as this is an ideal location to handle
event-driven logic. The RaisePostBackEvent event fires last in the series of
postback events due to the accuracy of the data that is rendered to the
browser.
Controls that are changed during postback should not
be updated after the executing function is called due to the consistency
factor. That is, data that is changed by an anticipated event should always be
reflected in the resulting page. The RaisePostBackEvent can be trapped by
catching RaisePostBackEvent, as in Figure 4.
Figure 4 - The RaisePostDataChanged and
RaisePostBackEvent events are defined by the IPostBackDataHandler interface.
7. Prerender the Objects
The point at which the objects are prerendered is
the last time changes to the objects can be saved or persisted to viewstate.
This makes the PreRender step a good place to make final modifications, such as
changing properties of controls or changing Control Tree structure, without
having to worry about ASP.NET making changes to objects based off of database
calls or viewstate updates. After the PreRender phase those changes to objects
are locked in and can no longer be saved to the page viewstate. The PreRender
step can be overridden using OnPreRender
8. ViewState Saved
The viewstate is saved after all changes to the page
objects have occurred. Object state data is persisted in the hidden object and
this is also where object state data is prepared to be rendered to HTML. At the
SaveViewState event, values can be saved to the ViewState object, but changes
to page controls are not. You can override this step by using SaveViewState, as
shown in Figure 5.
Figure 5 - Values are set for controls in
OnPreRender. During the SaveViewState event, values are set for the ViewState
object.
9. Render To HTML
The Render event commences the building of the page
by assembling the HTML for output to the browser. During the Render event, the
page calls on the objects to render themselves into HTML. The page then
collects the HTML for delivery. When the Render event is overridden, the
developer can write custom HTML to the browser that nullifies all the HTML the
page has created thus far. The Render method takes an HtmlTextWriter object as
a parameter and uses that to output HTML to be streamed to the browser. Changes
can still be made at this point, but they are reflected to the client only. The
Render event can be overridden, as shown in Figure 6 (below).
10. Disposal
After the page’s HTML is rendered, the objects are
disposed of. During the Dispose event, you should destroy any objects or
references you have created in building the page. At this point, all processing
has occurred and it is safe to dispose of any remaining objects, including the
Page object. You can override Dispose, as shown in Figure 6.
Figure 6 - The Render event will output custom HTML
to the browser through the HtmlTextWriter object.
Conclusion
Each time we request an ASP.NET page, we run through
the same process from initialization to disposal. By understanding the inner
workings of the ASP.NET page process, writing and debugging our code will be
much easier and effective (not to mention less frustrating).
Tech Interviews comment by Elango Kumar
3. I want a detailed
answer for the question.
1)Explain the life cycle of an ASP .NET page.
2)Explain the .NET architecture.
1) what r object oriented concepts?
a)
2)how do u create multiple inheritance in c# and .net?
a)
3)When web.config is called
a)
4)how many weg.configs a application can have
a)
5)how do u set language in weg.config
a)
6)what does connection string consists of
a)
7)where do u store connection string
a)
8)what is abstract class?
a)
9)what is diff b/w interface inhertance and class
inheritance
a)
10)what are the collection classes
a)
11)what are the types of thrading models?
a)
12)what inheritance support vb.net
a)
13)what is runtime host?
a)
14)OOPS CONCEPS
a)
15)optimization technique description
a)
16)diff b/w application and session
a)
17)what is web application virtual directory?
a)
18)diff b/w Active.exe and Dll
a)
19)connection pooling in MTS?
A)
20)if cookies is disabled in client browser will
session work
a)
21)how do u make your site SSL enabled
a)
22)did u work an IIS adminstration
a)
23)the following code execute successfully
response.write(“value of i=”+i);
a)
24)what are the provides available with vb.net?
a)
25)what is a Process,Sesion and Cookie.
a)
26)what are Abstrat base classes?
a)
27)what r the diff b/w bstract base classes and
Abstrat classes
a)
28)what r interface in .net?
a)
29)how is Polymorphism supports in .net?
a)
30)what r the 2 types of polymorphism supports in
.net?
a)
31)types of compatibilities and explain them
a)
32)
what is aggregative? How can it be implements in .net?
a)
33)diff b/w COM components and .net components?how
to register it
a)
34)diff b/w early binding and late binding?
a)
35)ASP.NET OBJECTS?
A)
36)asp.net life cycle? When request mode
a)
37)bout ado and its objects
a)
38)what is side by side execution
a)
39) what serialization?
a)
40)about a class access specifiers and method acess
specifiers
a)
41)what diff b/w overloading and overriding ? how
can this be .net
a)
42)about virtual function and then use
a)
how do u implement inhetance in .net?
a)
44)if I want to override a method 1 of class A and
this class B then how do u declared
a)
45)
About friend and protected friend
a)
46)bout multiple and multi_level Inhertance how to a
chive in .net?
a)
47)ALL kind of access specifiers for a class and for
methos?
a)
48)on ODP.NET
A)
49)what is nonpderterministic finalization?
a)
50)what is isPostback property?
a)
51)what is dictionary base class?
a)
52)how can a class be extended and how is this mechanism
difff from that of implementation an interface?
a)
53) What are indexes .net?
a)
54)How can indexeses be implemented in .net?
a)
Tech Interviews comment by murali
4. Do you not have
any cartagory for ‘C’ PROGRAMING LANGUAGE?
Tech Interviews comment by JAYANTA KARMAKAR
5. hi friends,
1. Can some body explain me the concept of boxing
and unboxing ?? Is this done exlpicitly or is done implicitly???? what is the
need of boxing??
2. What is viewstate in asp.net ??? Please explain
the concept of
viewstate??? Is this a property of web page or of asp.net server controls?
3. what is ISpostback method in asp.net ?
4.What is the diffrence between page_init() and
page_load() event?? Can we perform something page_init() which is visible to us
as a result ????
Please send me the answers at my email id rohit_afreen@rediffmail.com
Tech Interviews comment by Rohit Kochar
6. if you dont know
what is an abstract class, why in the hell are you postuling for a job?
Learn the language first then come to this site.
Tech Interviews comment by karine
7. Can Any one tell
me what is called web service in .net…
Actuallly I know what it is for but I just want to know in simple description…
Tech Interviews comment by Elango Kumar
8. Mr Murali
4)how many weg.configs a application can have
a)We can have more than one web.config file in an application
For the other details please
learn the language first & than visit this site so that before viewing this
site u will have a basic idea
The following set was set
in by a reader of the site:
Following
are the questions from an interview I attended for in C#, ASP.NET, XML and Sql
Server. I will try to add some more as soon as I recollect. Hope these
questions will be useful for people attending interviews in this area.
1.
What is the maximum length of a varchar field in SQL Server?
2.
How do you define an integer in SQL Server?
3.
How do you separate business logic while creating an ASP.NET
application?
4.
If there is a calendar control to be included in each page of
your application, and we do not intend to use the Microsoft-provided calendar
control, how do you develop it? Do you copy and paste the code into each and
very page of your application?
5.
How do you debug an ASP.NET application?
6.
How do you deploy an ASP.NET application?
7.
Name a few differences between .NET application and a Java
application?
8.
Specify the best ways to store variables so that we can access
them in various pages of ASP.NET application?
9.
What are the XML files that are important in developing an
ASP.NET application?
10.
What is XSLT and what is its use?
more interview questions - all Java and .NET interview questions
4
Comments »
1. q1. 8000 (nvarchar
= 4000)
q2. int
q3. use code behind (general answer)
q4. write your own user control and either register the control page level, or
load it at runtime
q5. use vs.net to debug with breakpoints and localwatch; enable page tracing
q6. use web setup project, or use vs.net to copy project, or just xcopy the
files over
q7. languages, .net platform specific
q8. session, cache, application level, database, external files, viewstate,
querystring
q9. web.config is used to store info on the webapp
q10.xslt lets you transform an xml document into a presentable format
just a quick post
observer*
Tech Interviews comment by Observer
2. 1:
It depends on what version of SQL Server. In 2K, it’s 8k. If you’re using
nvarchars, it’s half that.
2:
Use the int keyword. I’m not sure what the question is asking: if you want to
know what an int is defined as, it’s a 32-bit signed integer, from -(2^31 - 1)
to (2^31 - 1). Adding the unsigned keyword buys you one more bit.
3:
Many ways. A few: 1) create tiers, but the business logic in a different tier;
2) put it in a different assembly; 3) put it in SPs. There are more, but the
specific one you use should depend on your application. Each has pros and cons.
4:
Create a web control. If you’re using VS.NET, you’re only a few steps away from
drag-and-drop into any ASP.NET page.
5:
VS.NET makes it easy, if you have it; just run in debug mode and you can step
through your code. Otherwise, you’re doing a lot of Response.Write statements
or logging to a disk, or something of that sort.
6:
Assuming: 1) you’ve compiled in release mode, 2) you’ve satisfied all your
other procedural requirements (those depend on the group you’re working in)
and, 3) there’s existing web space that’s set up correctly, copy the aspx
files, then the dll files from the bin directory into a bin directory. Don’t
forget any ancillary files like web.config or other configuration files you may
have referred to in code. It’s really more complicated than that most of the
time, but those are the general steps.
8:
It’s always best to assume that your target environment will one day be
clustered. If it’s set up right, you should be able to use application
variables. It may not be, so it’s often wise to store them externally and write
access wrappers. “Externally” could mean in a DB or static files. If your
application is big and hardcore, setting up a web service on a “cluster
controller” to feed the cluster machines isn’t a terrible idea, either.
9:
Web.config is the most important. Specific configuration determines which
others might be important.
10:
XSLT transforms XML into XML. If you have an XML data file and you need to
change the variable names (e.g. — if some part of your data tier gives you XML,
but in the wrong format), XSLT will give you the right XML listing. It can also
be used to transform XML data into XHTML for display to the user. Some browsers
will do the XML-XHTML conversion automatically, but that’s a dangerous
assumption if you’re in a heterogenous environment.
I’m not going to answer #7. There are lots of
differences from the ground up. For one, you can’t compare Java to .NET. You
can compare J2EE to .NET, or Java to C#. I don’t compare the languages; I just
write in both. J2EE is a more defined environment, but Microsoft covers a lot
of the gaps with application software. There are entire books about this, and
most of them get into the religious questions.
Tech Interviews comment by Stephan Samuel
3. Ans - Q.5: To
debug precompiled components such as business objects and code-behind modules,
you need to generate debug symbols. To do this, compile the components with the
debug flags by using either Visual Studio .NET or a command line compiler such
as Csc.exe (for Microsoft Visual C# .NET) or Vbc.exe (for Microsoft Visual
Visual Basic .NET).
Using Visual Studio .NET1.
Open the ASP.NET Web Application project in Visual Studio .NET.
2. Right-click the project in the Solution Explorer and click Properties.
3. In the Properties dialog box, click the Configuration Properties folder.
4. In the left pane, select Build.
5. Set Generate Debugging Information to true.
6. Close the Properties dialog box.
7. Right-click the project and click Build to compile the project and generate
symbols (.pdb files).
C# .NET interview
questions
Good for
preparation and general self-testing, but too specific for the actual job
interview. This was sent in by a job applicant getting ready to step into the
.NET field in India.
1.
Are private class-level variables inherited? - Yes, but they
are not accessible, so looking at it you can honestly say that they are not
inherited. But they are.
2.
Why does DllImport not work for me? - All methods marked with the
DllImport attribute must be marked as public static extern.
3.
Why does my Windows application pop up a console window every
time I run it? - Make sure that the target type set in the project properties
setting is set to Windows Application, and not Console Application. If you’re
using the command line, compile with /target:winexe, not /target:exe.
4.
Why do I get an error (CS1006) when trying to declare a method
without specifying a return type? - If you leave off the return type on a method
declaration, the compiler thinks you are trying to declare a constructor. So if
you are trying to declare a method that returns nothing, use void. The
following is an example: // This results in a CS1006 error public static
staticMethod (mainStatic obj) // This will work as wanted public static void
staticMethod (mainStatic obj)
5.
Why do I get a syntax error when trying to declare a variable
called checked? - The word checked is a keyword in C#.
6.
Why do I get a security exception when I try to run my C# app? - Some security
exceptions are thrown if you are working on a network share. There are some
parts of the frameworks that will not run if being run off a share (roaming
profile, mapped drives, etc.). To see if this is what’s happening, just move
the executable over to your local drive and see if it runs without the
exceptions. One of the common exceptions thrown under these conditions is
System.Security.SecurityException. To get around this, you can change your
security policy for the intranet zone, code group 1.2, (the zone that running
off shared folders falls into) by using the caspol.exe tool.
7.
Why do I get a CS5001: does not have an entry point defined
error when compiling? - The most common problem is that you used a
lowercase ‘m’ when defining the Main method. The correct way to implement the
entry point is as follows: class test { static void Main(string[] args) {} }
8.
What optimizations does the C# compiler perform when you use the
/optimize+ compiler option? - The following is a response from a developer on
the C# compiler team: We get rid of unused locals (i.e., locals that are never
read, even if assigned). We get rid of unreachable code. We get rid of
try-catch with an empty try. We get rid of try-finally with an empty try. We
get rid of try-finally with an empty finally. We optimize branches over
branches: gotoif A, lab1 goto lab2: lab1: turns into: gotoif !A, lab2 lab1: We
optimize branches to ret, branches to next instruction, and branches to
branches.
9.
What is the syntax for calling an overloaded constructor within
a constructor (this() and constructorname() does not compile)? - The syntax for
calling another constructor is as follows: class B { B(int i) { } } class C : B
{ C() : base(5) // call base constructor B(5) { } C(int i) : this() // call C()
{ } public static void Main() {} }
10.
What is the equivalent to regsvr32 and regsvr32 /u a file in
.NET development? - Try using RegAsm.exe. Search MSDN on Assembly
Registration Tool.
11.
What is the difference between a struct and a class in C#? - From language
spec: The list of similarities between classes and structs is as follows.
Longstructs can implement interfaces and can have the same kinds of members as
classes. Structs differ from classes in several important ways; however,
structs are value types rather than reference types, and inheritance is not supported
for structs. Struct values are stored on the stack or in-line. Careful
programmers can sometimes enhance performance through judicious use of structs.
For example, the use of a struct rather than a class for a Point can make a
large difference in the number of memory allocations performed at runtime. The
program below creates and initializes an array of 100 points. With Point
implemented as a class, 101 separate objects are instantiated-one for the array
and one each for the 100 elements.
12.
My switch statement works differently than in C++! Why? - C# does not
support an explicit fall through for case blocks. The following code is not
legal and will not compile in C#:
13. switch(x)
14. {15. case 0: // do something
16. case 1: // do something as continuation of case 0
17. default: // do something in common with
18. //0, 1 and everything else
19. break;
20. }
To achieve the
same effect in C#, the code must be modified as shown below (notice how the
control flows are explicit):
class Test
{ public static void Main() { int x = 3;
switch(x)
{ case 0: // do something
goto case 1;
case 1: // do something in common with 0
goto default;
default: // do something in common with 0, 1, and anything else
break;
}
}
}
21.
Is there regular expression (regex) support available to C#
developers? - Yes. The .NET class libraries provide support for regular
expressions. Look at the System.Text.RegularExpressions
namespace.
22.
Is there any sample C# code for simple threading? - Yes:
23. using System;
24. using System.Threading;
25. class ThreadTest
26. {27. public void runme()
28. {29. Console.WriteLine(\"Runme Called\");
30. }
31. public static void Main(String[] args)
32. {33. ThreadTest b = new ThreadTest();
34. Thread t = new Thread(new ThreadStart(b.runme));
35. t.Start();
36. }
}
37.
Is there an equivalent of exit() for quitting a C# .NET
application? - Yes, you can use System.Environment.Exit(int exitCode) to exit
the application or Application.Exit() if it’s a Windows Forms app.
38.
Is there a way to force garbage collection? - Yes. Set all
references to null and then call System.GC.Collect(). If you need to have some
objects destructed, and System.GC.Collect() doesn’t seem to be doing it for
you, you can force finalizers to be run by setting all the references to the
object to null and then calling System.GC.RunFinalizers().
39.
Is there a way of specifying which block or loop to break out of
when working with nested loops? - The easiest way is to use goto:
40. using System;
41. class BreakExample
42. {43. public static void Main(String[] args) {44. for(int i=0; i<3; i++)
45. {46. Console.WriteLine(\"Pass {0}: \", i);47. for( int j=0 ; j<100 ; j++ )
48. {49. if ( j == 10)
50. goto done;
51. Console.WriteLine(\"{0} \", j);52. }
53. Console.WriteLine(\"This will not print\");
54. }
55. done:
56. Console.WriteLine(\"Loops complete.\");
57. }
}
58. Is it possible to
restrict the scope of a field/method of a class to the classes in the same
namespace? -
There is no way to restrict to a namespace. Namespaces are never units of
protection. But if you’re using assemblies, you can use the ‘internal’ access
modifier to restrict access to only within the assembly.
A representative
of a high-tech company in United Kingdom sent this in today noting that the
list was used for interviewing a C# .NET developer. Any corrections and
suggestions would be forwarded to the author. I won’t disclose the name of the
company, since as far as I know they might still be using this test for
prospective employees. Correct answers are in green color.
1) The C# keyword
‘int’ maps to which .NET type?
1. System.Int16
2. System.Int32
3. System.Int64
4. System.Int128
2) Which of these
string definitions will prevent escaping on backslashes in C#?
1. string s = #”n
Test string”;
2. string s = “’n
Test string”;
3. string
s = @”n Test string”;
4. string s = “n Test
string”;
3) Which of these
statements correctly declares a two-dimensional array in C#?
1. int[,]
myArray;
2. int[][] myArray;
3. int[2] myArray;
4. System.Array[2]
myArray;
4) If a method is
marked as protected internal who can access it?
1. Classes that are both
in the same assembly and derived from the declaring class.
2. Only methods that
are in the same class as the method in question.
3. Internal methods
can be only be called using reflection.
4. Classes
within the same assembly, and classes derived from the declaring class.
5) What is boxing?
a) Encapsulating
an object in a value type.
b) Encapsulating a
copy of an object in a value type.
c) Encapsulating a
value type in an object.
d) Encapsulating a copy of a value type in an object.
6) What compiler
switch creates an xml file from the xml comments in the files in an assembly?
1. /text
2. /doc
3. /xml
4. /help
7) What is a
satellite Assembly?
1. A peripheral
assembly designed to monitor permissions requests from an application.
2. Any DLL file used
by an EXE file.
3. An assembly
containing localized resources for another assembly.
4. An assembly
designed to alter the appearance or ‘skin’ of an application.
8) What is a
delegate?
1. A
strongly typed function pointer.
2. A light weight
thread or process that can call a single method.
3. A reference to an
object in a different process.
4. An inter-process
message channel.
9) How does
assembly versioning in .NET prevent DLL Hell?
1. The runtime checks
to see that only one version of an assembly is on the machine at any one time.
2. .NET
allows assemblies to specify the name AND the version of any assemblies they
need to run.
3. The compiler
offers compile time checking for backward compatibility.
4. It doesn’t.
10) Which “Gang of
Four” design pattern is shown below?
public class A {
private
A instance;
private
A() {
}
public
static
A Instance {
get
{
if (
A == null )
A = new A();
return
instance;
}
}
}
1. Factory
2. Abstract Factory
3. Singleton
4. Builder
11) In the NUnit
test framework, which attribute must adorn a test class in order for it to be
picked up by the NUnit GUI?
1. TestAttribute
2. TestClassAttribute
3. TestFixtureAttribute
4. NUnitTestClassAttribute
12) Which of the
following operations can you NOT perform on an ADO.NET DataSet?
1. A DataSet can be
synchronised with the database.
2. A
DataSet can be synchronised with a RecordSet.
3. A DataSet can be
converted to XML.
4. You can infer the
schema from a DataSet.
13) In Object
Oriented Programming, how would you describe encapsulation?
1. The conversion of
one type of object to another.
2. The runtime
resolution of method calls.
3. The exposition of
data.
4. The
separation of interface and implementation.