You are on page 1of 163

INTERVIEW QUESTIONS

1. What is Visual Studio .NET 2003?


A. Visual Studio .NET 2003 is the comprehensive, multi-
language development tool for rapidly building and integrating
XML Web services and applications. Visual Studio .NET 2003
offers a highly productive environment in which to develop a
broad range of Microsoft .NET—connected applications and
technologies. Using the high-performance Microsoft .NET
Framework run-time environment, Visual Studio .NET provides
you with powerful tools for designing, building, testing, and
deploying Web services and applications, as well as sharing best
practices and guidelines in a team environment.
2. What are the new features in Visual Studio .NET 2003?
A. Visual Studio .NET 2003 includes a range of enhancements
for the hobbyist, professional, mobile, and enterprise developer.
At the heart of every edition of Visual Studio .NET 2003 is the
new and improved .NET Framework 1.1, which assists
developers in creating fast, scalable applications. Mobile
application developers now have the ability to create browser-
based applications for mobile devices or smart client
applications for the Pocket PC. Using the integrated ASP.NET
Web Forms and the Visual Studio .NET Web Forms Designer,
developers can easily build thin-client, Web-based applications
that intelligently render on more than 200 devices including
wireless application protocol (WAP) mobile phones, personal
digital assistants (PDAs), and pagers. Visual Studio .NET 2003
also includes integrated support for the Microsoft .NET
Compact Framework. Using the Microsoft Windows® Forms
designer, Microsoft Visual Basic® and C# developers can build,
debug, and deploy applications for the Pocket PC, Pocket PC
Phone Edition, and other smart devices powered by the .NET
Compact Framework. Integrated emulation enables developers
to program and debug their applications without requiring a
device. These features are available in Visual Studio .NET 2003
Professional, Visual Studio .NET 2003 Enterprise, and Visual
Studio .NET 2003 Enterprise Architect editions.
Visual Studio .NET 2003 includes a number of enhancements
for the C++ developer including greater ISO conformance (98
percent), new compiler optimizations including /G7 for
generating optimized code for Intel Pentium IV and AMD
Athlon processors, access to the shared Visual Studio .NET
Forms Designer, and more.
3. Can I use Visual Studio 6.0 and Visual Studio .NET 2003
on the same computer?
A. Yes, you can install Visual Studio .NET 2003 on a computer
that is running Visual Studio 6.0 and use both, system
requirements permitting.
4. Can I install Visual Studio .NET 2002 and Visual Studio
.NET 2003 on the same machine?
A. Yes, you can install Visual Studio .NET 2002 and Visual
Studio .NET 2003 on the same computer, system requirements
permitting.
5. Where is the Visual InterDev Web development system?
A. Microsoft Visual InterDev® is included in the Visual Studio
.NET integrated development environment (IDE). All languages
have access to the Web development capabilities that were
previously unique to Visual InterDev version 6.0.
6. Where are the Professional and Enterprise editions of
Visual Basic .NET 2003 and Visual C++ .NET 2003?
A. The functionality previously available in Professional and
Enterprise editions of the individual language products is now
available in the Professional and Enterprise editions of Visual
Studio .NET 2003. A new Visual Studio .NET Enterprise
Architect edition is also available with tools, including
Microsoft Visio® Enterprise Architect edition, specifically
designed for software architects building enterprise software.
7. Can my Visual Basic 6.0 applications be upgraded to
Visual Basic .NET 2003?
A. Yes. Visual Basic .NET 2003 Standard and Visual Studio
.NET 2003 Professional, Enterprise Developer, and Enterprise
Architect editions include an upgrade wizard that automatically
upgrades Visual Basic 6.0 projects when they are opened in
Visual Basic .NET 2003. The upgrade wizard modifies the
language for syntax changes and converts Visual Basic 6.0
forms to Windows Forms. In addition, the upgrade wizard
generates a report that alerts you to any manual changes that
need to be made in your code. Comments are displayed as tasks
in the Task List window, and you can navigate to the code
statement simply by double-clicking a task item.
8. How does Visual C++ support Microsoft .NET?
A. You can use Microsoft Visual C++® to produce code
for.NET—connected applications. In addition, Microsoft has
improved the Active Template Library (ATL), Microsoft
Foundation Classes (MFC), and the compiler in Visual C++
.NET. Microsoft has also introduced ATL Server, a set of
extensions to the Active Template Library, for producing native-
code Web service applications.
9. Does Visual Studio .NET 2003 work on Microsoft
Windows 95, Windows 98, and Windows Millennium Edition
(Windows Me) operating systems?
A. These platforms are not supported at design time. This
decision was made to ensure that you would be able to benefit
from the most advanced platform features available today. For
code execution, Microsoft Windows 98 and later editions are
supported.
10. How does .NET support my existing COM and COM+
components?
A. The .NET Framework enables you to call existing
Component Object Model (COM) and COM+ components. It
also enables .NET Framework—connected components to be
exposed to COM and COM+ development. Additionally, a
considerable amount of COM+ 1.0 "plumbing" has been
simplified in the .NET Framework.
11. Can I benchmark the Microsoft .NET Framework?
A. Yes. As per the licensing agreement, customers can setup and
run their own benchmarks of the .NET framework for technical
evaluation purposes. You may not disclose the results of any
benchmark test of the .NET Framework to any external third
party outside your organization without Microsoft’s prior
written approval. You can email benchnet@microsoft.com for
more specific details on obtaining this approval.
12. What is the .NET Compact Framework?
A. The .NET Compact Framework brings .NET-connected
applications to smart, mobile devices—including Pocket PC
and Pocket PC 2002. With Visual Studio .NET 2003, you can
create smart device applications for these devices using the same
tools, code, and techniques that you use on the desktop.
13. What is Visual J# .NET?
A. Microsoft Visual J#™ .NET makes it possible for Java
developers to use the language of their choice to program .NET
—connected applications. With Visual J# .NET, programmers
can build robust .NET-connected applications that interoperate
with applications written in any other language supported by
Microsoft .NET. With Visual J# .NET, Java-language developers
can use the rich tools of the .NET Framework (ADO.NET,
ASP.NET, and others) where the functionality and simplicity
surpass what is available in the Java developer kit (JDK)
specifications.
14.What is late binding and early binding?
There are two different ways of implementing OLE
Automation: VTBL (virtual method table, pronounced V-
Table) binding, and the IDispatch (pronounced EYE-
Dispatch) interface.
Early Binding: VTBL Binding
A VTBL is a data structure containing the addresses
(pointers) for the methods and properties of each object in
an Automation server. Using the VTBL is generally known
as early binding in VBA. Frequently, early binding requires
type information provided in the form of a type library.
This type information allows VBA to perform compile-time
syntax and type checking. At run time, this type of binding
is faster, as the entry points for the Automation server are
already known and the data types and syntax have already
been verified.
Late Binding: The IDispatch Interface
Using the IDispatch interface is a way to call member
functions within an object without knowing the exact
location of their entries in the VTBL. An IDispatch
implementation is frequently referred to as late binding.
With IDispatch, VBA has no preexisting information about
the server it will be calling. It assumes during its compile
phase that the code is correct. It then attempts at run time to
execute the code and trap for run-time errors. This is much
less elegant and represents a step backward from the
familiar syntax and type checking we have come to expect
from VBA. An IDispatch call also requires both the client
and the server to marshal their arguments into a consistent
form that is understood by both. In most cases, this means
that arguments are copied into and out of variants. This not
only slows down IDispatch, but it also limits the data types
that can be passed using this technique. In all future
discussions VTBL binding will be referred to as early
binding and IDispatch as late binding.
Early binding not only increases performance, but you get
syntax and type checking at compile-time. If you can't early
bind you must use late binding, which is slower and doesn't
allow you to catch simple errors (such as type mismatches)
until run time.
Early binding should be used whenever possible. However,
there are programming situations in which late binding is
preferred. If you are implementing polymorphic code (one
call can represent multiple different objects), then late
binding is required. For example, you can create three
classes — widgets, gidgets, and gadgets — all with a
Create method. By defining your variable as an object, you
can call the Create method for any of the three classes
based on run-time conditions.
When testing this type of late-bound strategy, it's generally
best to test a single object, early bind to get the syntax and
type checking, and then switch to late binding after you've
tested each object individually.
15.How do you handle errors in VB?
a. On Error Resume Next
b. On Error GoTo
c. On Error GoTo 0
16.Question on on error goto 0?
d. To neutralize On Error Resume Next
17.How are structures implemented in VB?
e. Type

18.What are the threading models that you can choose in


VB? Which one will you recommend and why?
Apartment Threading model.
Because in this model the COM object is instantiated only
on the first call to it.
19.Compatibility settings in vb?
The Compatibility setting allows you to determine the
Visual Basic project's compatibility to older versions of the
ActiveX Components generated from the project.
The ActiveX Components you create contain a default
interface (for example, CName_D where CName is the
ClassName for the ActiveX Component) that contains all of
the methods and properties you have created. If your Class
raises events, you also have an additional interface called
IConnectionPointContainer. When you build an ActiveX
Control or Server, these Interfaces are given a unique
identifier. If you modify your control or server, these
interfaces may change. Any applications using an older
version of your component may fail at this point. To ensure
that your new and old interfaces will work with all
applications, you need to set the appropriate Compatibility
setting.
You can set the Project's Compatibility in the
Project\Properties dialog box, under the Component tab.
Visual Basic has three different compatibility settings for
Projects:
• No compatibility.
• Project compatibility.
• Binary compatibility.
No Compatibility
With this setting, no compatibility is enforced. Visual Basic
creates new Interface IDs and Class IDs every time you
build or compile your project. Each version built can only
be used with applications created to work with that specific
build of the component.
Project Compatibility
With this setting, you can make your project compatible to
a specific component project. While new type library
information is generated, the type library identifier is
maintained so that test projects can still refer to the
component project. This setting is for maintaining
compatibility during testing. Therefore, once the
component is released, it behaves the same as the No
Compatibility setting.
Binary Compatibility
When you compile your project, Visual Basic only creates
new Class and Interface IDs when necessary. It preserves
the class and interface IDs from the previous version(s) so
that programs compiled using an earlier version will
continue to work. If you are making a change that will
result in an incompatible version, Visual Basic will warn
you. If you want to maintain compatibility with older,
released versions of an ActiveX component, this is the
setting you need to use.

20.What is the necessity for Resume Next?


f. To continue executing the code even a runtime error
occurs.

21.What is the difference between COM and DCOM?


a. DCOM is used to work with components located in
different machines.
b. COM is a Specification
c. DCOM is a Model/Implementation
22.What is the default interface for any COM component?
d. IUnKoown
23.What are the methods available in IUnknown?
e. QueryInterface, AddRef, Release
24.What is IDispatch?
f. Ref Attachment IDispatch
25.What is the diffrence between activex exe and activex
dll?
Components are characterized by their location relative to
clients. An out-of-process component is an .exe file that
runs in its own process, with its own thread of execution.
Communication between a client and an out-of-process
component is therefore called cross-process or out-of-
process communication.
An in-process component, such as a .dll or .ocx file, runs in
the same process as the client. It provides the fastest way of
accessing objects, because property and method calls don’t
have to be marshaled across process boundaries. However,
an in-process component must use the client’s thread of
execution.
In-process components execute in the process space of the
calling application; out-of-process components execute in
their own distinct process space. When an application (any
.exe file) starts, Windows creates a process space in which
the application runs. This process space gets its own
memory address space that's inaccessible to other
processes. When an application instantiates an object from
an in-process component (DLL, OLE custom control—
OCX), code executes in the calling application. This calling
application is called the client. The in-process component
can share the memory address space of the client
application.

26.What are the VBScript Data Types?


VBScript has only one data type and it's called a Variant. A
Variant is a special kind of data type that can contain
different kinds of information, depending on how it's used.
Because Variant is the only data type in VBScript, it's also
the data type returned by all functions in VBScript.
At its simplest, a Variant can contain either numeric or string
information. A Variant behaves as a number when you're using
it in a numeric context and as a string when you use it in a string
context. That is, if you're working with data that looks like
numbers, VBScript assumes that it is numbers and does the
thing that is most appropriate for numbers. Of course, you can
always make numbers behave as strings, by enclosing them in
quotation marks. Similarly, if you're working with data that can
only be string data, VBScript treats it as string data.
Beyond the simple numeric or string classifications, a Variant
can make further distinctions about the specific nature of
numeric information. For example, you can have numeric
information that represents a date or a time. When used with
other date or time data, the result is always expressed as a date
or a time. Of course, you can also have a rich variety of numeric
information ranging in size from Boolean values to huge
floating-point numbers. These different categories of
information that can be contained in a Variant are called
subtypes. Most of the time, you can just put the kind of data you
want in a Variant and it behaves in a way that is most
appropriate for the data it contains.
27. Are vbscript, vb strongly typed languages?
1. A language is strongly typed if type annotations are
associated with variable names, rather than with values. If
types are attached to values, it is weakly typed.
2. A language is strongly typed if it contains compile-time
checks for type constraint violations. If checking is
deferred to run time, it is weakly typed.
3. A language is strongly typed if there are compile-time or
run-time checks for type constraint violations. If no
checking is done, it is weakly typed.
4. A language is strongly typed if conversions between
different types are forbidden. If such conversions are
allowed, it is weakly typed.
5. A language is strongly typed if conversions between
different types must be indicated explicitly. If implicit
conversions are performed, it is weakly typed.
6. A language is strongly typed if there is no language-level
way to disable or evade the type system. If there are casts
or other type-evasive mechanisms, it is weakly typed.
7. A language is strongly typed if it has a complex, fine-
grained type system with compound types. If it has only a
few types, or only scalar types, it is weakly typed.
8. A language is strongly typed if the type of its data objects is
fixed and does not vary over the lifetime of the object. If
the type of a datum can change, the language is weakly
typed.
VbScript is not strongly typed but VB is .

28.Are you concatenating strings in components?


Use fixed-length strings in Visual Basic for string concatenation.
Don't just keep adding to a string, or you'll reallocate it multiple
times -- and reallocation is expensive.
29.Are you using transactions when you don't need to?
Transactions provide a service -- and that service can add a
performance hit. Evaluate whether methods actually need
transactions. For example, if you're grabbing a recordset to hand
off to a browser client for reading data, you don't need a
transaction. By factoring out operations that read data into
separate components from operations that perform updates, you
have more flexibility in marking your components for
transactions.
30.Are you calling SetComplete/SetAbort in each method?
Calling SetComplete and SetAbort in each method of your
Microsoft Transaction Server (MTS) components will release
resources earlier, and will ensure that a component does not live
outside the scope of its transaction. In Windows 2000, COM+
provides the setting 'Automatically deactivate this object when
this method returns,' which performs the equivalent code. You
can enable this setting on a per-method basis in the Component
Services console.
31.Are you crossing processes effectively?
Minimizing marshaling overhead and reducing network calls are
keys to improving performance of distributed applications. Use
early binding in your components to minimize expensive
network round trips by eliminating the extra call to
GetIdsOfNames that late binding incurs. You can further reduce
network trips by bundling your parameters into arguments for
method calls, instead of setting a bunch of properties
individually. Rather than pass parameters ByRef, pass ByVal
where you can to minimize marshaling overhead.
32.Are you using indexes in your database?
Indexes provide immediate impact on your application's
performance. Poor indexes will slow your application to a crawl,
while good indexes will help optimize your application's
performance.
33.Are you calling stored procedures rather than dynamic
SQL?
Using stored procedures prevents your database from having to
recompile your SQL statements repeatedly. Use stored
procedures or parameterized SQL strings.
34.Are you returning just the required data?
Check your SELECT statements to ensure that you're returning
only the required columns and only the necessary rows. If you
have queries that can potentially return a lot of records, consider
paging through your recordsets.
35.Are you storing ADO connection in Session or Application
scope?
This defeats the purpose of connection pooling and creates
resource contention. Create connection at page scope or within
the functions that need them, and set the connections to nothing
to free the connection back to the pool.
36.Are you explicitly closing Recordset and Connection
variables?
Recordsets need to be closed if they are going to be reused (but
reusing recordsets is discouraged). Closing Connection variables
as soon as you can releases them back to the pool, so that they
can be pooled for reuse. It is always good practice to explicitly
close your object variables.
37.Are you reusing Recordset and Command variables?
Create new Recordset and Command variables rather than
reusing existing ones. This won't necessarily improve your
application's performance but it will make your application more
reliable and easier to maintain.
38.Are you disconnecting the recordsets?
Disconnecting recordsets frees the Connection object back to the
pool, allowing the Connection to be closed and reused sooner.
39.Are you using the right cursor and lock-type for the job?
Use "Firehose" (forward-only, read-only) cursors when you need
to make a single pass through the data. Firehose cursors, the
default in ADO, provide the fastest performance and have the
least amount of overhead.
40.Are you using DSN-less connections?
In general, DSN-less connections are faster than System
DSNs (data source names), which are faster than File
DSNs.
41. What are the different types of objects available in
ADO.Net?
Two key elements are .net data provider (set of components) and
dataset.
Objects in ADO.Net
Connection: For connection to and managing transactions
against a database.
Command: For issuing SQL commands against a database.
DataReader : For reading a forward-only stream of data records
from a data source.
DataSet : For storing, remoting and programming against flat
data, XML data and relational data.
DataAdapter: For pushing data into a DataSet, and reconciling
data against a database.
Note: There are two sets of objects for
Connection/Command/DataReader/DataAdapter
Namespace : System.Data.SqlClient (Specific to SQL Server)
sqlConnection, sqlCommand, sqlDataReader and
sqlDataAdapter
Namespace : System.Data.Oledb (For other data sources)
oledbConnection, oledbCommand, oledbDataReader and
oledbDataAdapter
42. What are the new object introduced in ado.net that are
nor there in ADO
Dataset, Datareader, Datatable
43. What is the diff. bet DataReader & DataSet?
Datareader need all the time to be connected to the datasource
but dataset is disconnected one.
Datareader is forward, read only.
44. What are the Database related classes available in .Net?
Sqlconnection, sqlcommand, sqldataadapter, sqldatareader,
oledbconnection, oledbcommand, oledbdataadapter,
oledbdatareader,
Dataset, Datatable
45. Maintaining transactions in ADO.net
There are two ways to handle transactions in updating data
source.
Database Transactions
Transactions can be handled in the database itself using stored
procedures.
BEGIN TRANSACTION, COMMIT TRANSACTION,
ROLLBACK TRANSACTION
Connection Based Transactions
We can make use of connection object to handle the
transactions.
Connection.BeginTransaction, Transaction.Commit,
Transaction.Rollback
We can create transaction object by
Dim objTran as sqlTransaction
Cn.open()
objTran = cn.BeginTransaction
assigning transaction object to the command object
objCommand.Transaction = objTran
finally you can call the following statements according to your
conditions
objTran.Commit()
or
objTran.Rollback()
46. Which class you have commonly used from the
System.Data namespace
Dataset , Datatable, DataRelation
47.What is boxing and unboxing?
Boxing is an implicit conversion of a value type to the type
object or to any interface type implemented by this value type.
Boxing a value of a value allocates an object instance and copies
the value into the new object.
Unboxing is an explicit conversion from the type object to a
value type or from an interface type to a value type that
implements the interface. An unboxing operation consists of:
• Checking the object instance to make sure it is a boxed
value of the given value type.
• Copying the value from the instance into the value-type
variable.
48.What are the different types of objects available in
ADO.Net.
The Central components of ADO.NET are
Dataset  The ADO.NET DataSet is the core component of the
disconnected architecture of ADO.NET. The DataSet is
explicitly designed for data access independent of any data
source. As a result it can be used with multiple and differing
data sources, used with XML data, or used to manage data local
to the application. The DataSet contains a collection of one or
more DataTable objects made up of rows and columns of data,
as well as primary key, foreign key, constraint, and relation
information about the data in the DataTable objects
DataTableCollection
DataTable
DataRowCollection
DataColumnCollection
ConstraintCollection
DataRelationCollection

.Net Data providers 


Connection: Establishes a connection to a specific data source.
Command: Executes a command against a data source. Exposes
Parameters and can execute within the scope of a Transaction
from a Connection.
DataReader: Reads a forward-only, read-only stream of data
from a data source.
DataAdapter: Populates a DataSet and resolves updates with
the data source.

49.. How ADO.Net differs from ADO.


i. ADO .NET does not replace ADO rather it provides .Net
programmer with access to relational data sources, XML
and Appln data.
ii. ADO .NET similar to ADO + several new concepts in
design + better interoperability and scalable data access
iii. Improved integration with XML
iv. Improved support for disconnected model (ADO had the
same using cursor location)
v. Improved design time support
vi. ADO u have a single obj that behaves in many diff ways
viz recordset (keeps object model simple)
vii. vii. ADO .NET has object viz; DataReader (forward only
readonly), DataSet (in memory relational representation of
data), DataAdapter (bridge betw data source and dataset)
viii. ADO .NET has command obj that supports
ExecuteNonQuery () and ExecuteScalar
ix. Data can be loaded from db, XML or can be application
generated
x. In ADO communication to b happens thro OLE DB
provider, where as in ADO .NET the communication
happens thro DataAdapter which in turn makes calls to
OLE DB providers or APIs provided
xi. Using ADO .NET it is possible to transmit data betwn
applns where as in ADO u need to use disconnected
recordsets to pass recordsets betwn components and u need
to use COM marshalling (and requires the data types to be
converted to COM data types when marshalling)
xii. Firewalls prevent transmit of data between components
using COM Marshalling where as in ADO .NET firewalls
does not create a problem as the data is passed in XML
format.
xiii. ADO.NET has minimized Database connections

50. What is a Web Service? Give an example.


Web Services are programmable business logic components that
serve as “black boxes” to provide access to functionality via
internet using standard protocols such as HTTP. Web services
are based upon an application of XML called SOAP
SOAP stands for Simple Object Access Protocol. It is a
communication protocol for sending information between
application over internet via HTTP.

51. what is format of WSDL?


WSDL stands for Web service description language
It is as xml based language for describing web services & how
to access the web service. It specifies the location of the service
and the operations (or methods) the service exposes.
Universal Description, Discovery and Integration (UDDI) is a
directory service where businesses can register and search for
Web services. It is a directory for storing web services and
communicated via SOAP.
52.What is the difference between recordset and dataset?
A recordset looks like a single table. If a recordset is to
contain data from multiple database tables, it must use a JOIN
query, which assembles the data from the various database tables
into a single result table.
In contrast, a dataset is a collection of one or more tables. The
tables within a dataset are called data tables; specifically, they
are DataTable objects. If a dataset contains data from multiple
database tables, it will typically contain multiple DataTable
objects. That is, each DataTable object typically corresponds to
a single database table or view. In this way, a dataset can mimic
the structure of the underlying database.
A dataset usually also contains relationships. A relationship
within a dataset is analogous to a foreign-key relationship in a
database —that is, it associates rows of the tables with each
other. For example, if a dataset contains a table about investors
and another table about each investor's stock purchases, it could
also contain a relationship connecting each row of the investor
table with the corresponding rows of the purchase table.
53.What are the new object introduced in ADO.NET that are
not there in ADO?
DataAdapter, DataReader, DataSet & its collection.
54.Briefly describe the major components of the .NET
Framework and describe what each component does.
The .NET Framework consists of two primary parts: the
common language runtime, which manages application
execution, enforces type safety, and manages memory
reclamation, and the .NET base class library, which consists
of thousands of predeveloped classes that can be used to
build applications.
55.Briefly explain what is meant by a reference type and a
value type.
A value type holds all of the data represented by the
variable within the variable itself. A reference type contains
a reference to a memory address that holds the data instead
of the actual data itself.
56.How do you enable your application to use .NET base
class library members without referencing their fully
qualified names?
Use the Imports keyword (Visual Basic .NET) or the using
keyword (Visual C#) to make a .NET Framework
namespace visible to your application.
57.Briefly describe how garbage collection works.
The garbage collector is a thread that runs in the
background of managed .NET applications. It constantly
traces the reference tree and attempts to find objects that
are no longer referenced. When a nonreferenced object is
found, its memory is reclaimed for later use.
58.Briefly describe what members are, and list the four
types of members.
Members are the parts of a class or a structure that hold
data or implement functionality. The primary member types
are fields, properties, methods, and events.
59.Explain what constructors and destructors are and
describe what they are used for.
The constructor is the method that initializes a class or
structure and is run when a type is first instantiated. It is
used to set default values and perform other tasks required
by the class. A destructor is the method that is run as the
object is being reclaimed by garbage collection. It contains
any code that is required for cleanup of the object.
60.Briefly explain the difference between Public (public),
Friend (internal), and Private (private) access levels as they
apply to user-defined types and members.
In user-defined types, Public (public) classes can be
instantiated by any element of the application. Friend
(internal) classes can be instantiated only by members of
the same assembly, and Private (private) classes can be
instantiated only by themselves or types they are nested in.
Likewise, a Public (public) member can be accessed by any
client in the applica-tion, a Friend (internal) member can be
accessed only from members of the same assembly, and
Private (private) members can be accessed only from
within the type.
61.Do you need to instantiate a class before accessing a
Shared (static) member? Why or why not?
Because a Shared (static) member belongs to the type
rather than to any instance of the type, you can access the
member without first creating an instance of the type.
63.Describe two ways to set the tab order of controls on
your form.
You can set the tab order in Visual Studio by choosing Tab
Index from the View menu and clicking each control in the
order you desire. Alternatively, you can set the TabIndex
property either in code or in the Properties window.
64.What is an extender provider, and what does one do?
Extender providers are components that provide additional
properties to controls on a form. Examples include the
ErrorProvider, HelpProvider, and ToolTip components.
They can be used to provide additional information about
particular controls to the user in the user interface.
65.Explain when you might implement a shortcut menu
instead of a main menu.
If every possible option is exposed on a main menu, the
menu can become busy and hard to use. Shortcut menus
allow less frequently used options to be exposed only in
situations where they are likely to be used.
66.Describe what is meant by field-level validation and
form-level validation.
Field-level validation is the process of validating each
individual field as it is entered into a form. Form-level
validation describes the process of validating all of the data
on a form before submitting the form.
67.Explain when a type conversion will undergo an
implicit cast and when you must perform an explicit cast.
What are the dangers associated with explicit casts?
Types can be implicitly converted when the conversion can
always take place without any potential loss of data. When
a potential loss of data is possible, an explicit cast is
required. If an explicit cast is improperly performed, a loss
of data precision can result, or an exception can be thrown.
68.Explain why you might use enums and constants
instead of their associated literal values.
Enums and constants make code easier to read and
maintain by substituting human-legible tokens for
frequently used constant values.
69.Briefly summarize the similarities and differences
between arrays and collections.
Arrays and collections allow you to manage groups of
objects. You can access a particular object by index in both
arrays and collections, and you can use For Each...Next
(foreach) syntax to iterate through the members of arrays
and most collections. Arrays are fixed in length, and
members must be initialized before use. Members of
collections must be declared and initialized outside of the
collection, and then added to the collection. Collections
provided in the System.Collections namespace can grow or
shrink dynamically, and items can be added or removed at
run time.
70.Explain how properties differ from fields. Why would
you expose public data through properties instead of
fields?
Properties allow validation code to execute when values are
accessed or changed. This allows you to impose some
measure of control over when and how values are read or
changed. Fields cannot perform validation when being read
or set.
71.Explain what a delegate is and how one works.
A delegate acts like a strongly typed function pointer.
Delegates can invoke the methods that they reference
without making explicit calls to those methods.
72.Briefly explain encapsulation and why it is important
in object-oriented programming.
Encapsulation is the principle that all of the data and
functionality required by an object be contained by that
object. This allows objects to exist as independent,
interchangeable units of functionality without maintaining
dependencies on other units of code.
73.What is method overloading, and when is it useful?
Method overloading allows you to create several methods
with the same name but different signatures. Overloading is
useful when you want to provide the same or similar
functionality to different sets of parameters.
74.You need to create several unrelated classes that each
exposes a common set of methods. Briefly outline a
strategy that will allow these classes to polymorphically
expose that functionality to other classes.
Factor the common set of methods into an interface, and
then implement that interface in each class. Each class can
then be implicitly cast to that interface and can
polymorphically interact with other classes.
75.You need to create several classes that provide a core
set of functionality but each must be able to interact with
a different set of objects. Outline a strategy for developing
these classes with the least development time.
Create a single class that implements all of the common
functionality required by these classes. Then, use
inheritance to create derived classes that are specific for
each individual case.
76.Describe an abstract class and explain when one might
be useful.
An abstract class is a class that cannot be instantiated but
must be inherited. It can contain both implemented
methods and abstract methods, which must be implemented
in an inheriting class. Thus, it can define common
functionality for some methods, a common interface for
other methods, and leave more detailed implementation up
to the inheriting class.
77.Describe Break mode and some of the available
methods for navigating in Break mode.
Break mode allows you to observe program execution on a
line-by-line basis. You can navigate program execution in
Break mode by using Step Into, Step Over, Step Out, Run
To Cursor, and Set Next Statement.
78.When would you use the Watch window?
You would use the Watch window to observe the values of
application variables while in Break mode.
79.You are deploying a beta version of a large application
and want to collect performance data in text files while the
application is in use. Briefly describe a strategy for
enabling this scenario.
Place Trace statements that report the data of interest
throughout the application. Create a
TextWriterTraceListener and add it to the Listeners
collection. Create Trace switches that control when Trace
statements are executed. Configure the
TextWriterTraceListener to write output to a text file. Then,
compile and deploy the application with Trace defined, and
enable the Trace switches in the application .config file.
80.When testing a method, should you test data that is
known to be outside of the bounds of normal operation?
Why or why not?
Yes. In addition to testing normal data operation, you must
test known bad input to ensure that your application can
recover from input errors without a catastrophic application
failure.
81.Briefly explain what each segment of a
Try...Catch...Finally (try...catch...finally) block does.
The Try (try) block encloses code that is to be executed. If
an exception is thrown, it can be caught in an appropriate
Catch (catch) block where code that will allow the
application to handle the execution will be executed. The
Finally (finally) block contains any code that must be
executed whether or not the exception is handled.
82.What are the major components of a Data Provider,
and what function does each fulfill?
An ADO.NET Data Provider is a suite of components
designed to facilitate data access. Every Data Provider
minimally includes a Connection object that provides the
actual connection to the data source, a Command object
that represents a direct command to the data source, a
DataReader object that provides connected, forward-only,
read-only access to a database, and a DataAdapter that
facilitates disconnected data access.
83.Briefly contrast connected and disconnected data
access in ADO.NET.
In ADO.NET, connected data access is available through
the DataReader, which is a lightweight class designed to
provide very fast and efficient data access. It is severely
limited, however, in that it can only provide forward-only
data access, it does not allow editing, and it requires the
exclusive use of a Connection object. In contrast,
disconnected data access is facilitated by a DataAdapter,
which manages the commands required for selecting and
updating data. The DataAdapter executes a SELECT
command against a database, opening a data connection
just long enough to retrieve the data, and loads the data into
a DataSet, which is an in-memory copy of the data. When
the data is ready to be updated, the Data Provider manages
the updates in the same way, generating the appropriate
commands to update the database and keeping the
connection open just long enough to execute those
commands.
84.What are the three possible settings for the
CommandType property of a SqlCommand object or an
OleDbCommand object, and what does each mean?
A Command object can have a CommandType property
setting of Text, StoredProcedure, or TableDirect. When set
to Text, the command executes the SQL string that is stored
in the Command object's CommandText property. When set
to StoredProcedure, the command accesses a procedure
stored on the database and returns the results. A
CommandText setting of TableDirect indicates that the
command should return the entire contents of the table
indicated by the CommandText property.
85.How could you execute DDL commands, such as
ALTER or CREATE TABLE, against a database with
ADO.NET?
You must use a Command object to execute DDL
commands. You can set the CommandType property to Text
and enter the appropriate DDL command in the
CommandText property. Then call
Command.ExecuteNonQuery to execute the command.
86.Briefly discuss the advantages and disadvantages of
using typed DataSet objects.
Typed DataSet objects allow you to work with data that is
represented as members of the .NET common type system.
This allows your applications to be aware of the types of
data returned in a DataSet and serves to eliminate errors
resulting from invalid casts, as any type mismatches are
caught at compile time. Untyped DataSet objects, however,
are useful if you do not know the structure of your data,
and can be used with any data source.
87.How can you manage data currency on a form with
several bound controls?
Every data source on a form has an associated
CurrencyManager object that keeps that of the "current"
record with respect to bound controls. For convenience, all
of the CurrencyManager objects represented on a form are
exposed through the form's BindingContext property. The
Position of the CurrencyManager can be changed, allowing
navigation through the records.
88.Describe how to use a DataView to filter or sort data.
You can apply sort criteria to a DataView by setting the
Sort property to the name of a column or columns to be
sorted by. The data represented in a DataView object can be
filtered by setting the RowFilter property to a valid filter
expression.
89.Briefly describe an XmlDataDocument and how it
relates to a DataSet.
An XmlDataDocument is an in-memory representation of
data in a hierarchical Xml format. Each XmlDataDocument
is synchronized with a DataSet. Whenever changes are
made to one object, the other is instantly updated. Thus,
you can use the XmlDataDocument to perform XML
manipulations on a DataSet.
90.Briefly describe the three types of user-developed
controls and how they differ.
The three types of user-developed controls are inherited
controls, user controls, and custom controls. An inherited
control derives from a standard Windows Forms control
and inherits the look, feel, and functionality of that control.
User controls allow you to combine standard Windows
Forms controls and bind them together with common
functionality. Custom controls inherit from Control and are
the most development-intensive kind of control. Custom
controls must implement all their own code for painting
and inherit only generic control functionality. All specific
functionality must be implemented by the developer.
91.Describe the roles of Graphics, Brush, Pen, and
GraphicsPath objects in graphics rendering.
The Graphics object represents a drawing surface and
encapsulates methods that allow graphics to be rendered to
that surface. A Brush is an object that is used to fill solid
shapes, and a Pen is used to render lines. A GraphicsPath
object represents a complex shape that can be rendered by a
Graphics object.
92.Describe the general procedure for rendering text to a
drawing surface.
You must first obtain a reference to a Graphics object.
Next, create an instance of a GraphicsPath object. Use the
GraphicsPath.AddString method to add text to the
GraphicsPath. Then, call the Graphics.DrawPath or
Graphics.FillPath to render the text.
93.Describe the role of the LicenseProvider in control
licensing.
The LicenseProvider controls license validation and grants
run-time licenses to validly licensed components. The
LicenseManager.Validate method checks for an available
license file and checks against the validation logic provided
by the specific implementation of LicenseProvider. You
specify which LicenseProvider to use by applying the
LicenseProviderAttribute.
94.Describe how to create a form or control with a
nonrectangular shape.
Set the Region property of the form or control to a Region
object that contains the irregular shape. You can create a
Region object from a GraphicsPath object.
95.Briefly describe how to use the PrintDocument
component to print a document. Discuss maintaining
correct line spacing and multipage documents.
The PrintDocument class exposes the Print method, which
raises the PrintPage event. Code to render printed items to
the printer should be placed in the PrintPage event handler.
The PrintPage event handler provides the objects required
to render to the printer in an instance of the
PagePrintEventArgs class. Content is rendered to the
printer using the Graphics object provided by
PagePrintEventArgs. You can calculate correct line spacing
by dividing the height of the MarginBounds property by the
height of the font you are rendering. If your document has
multiple pages, you must set the
PagePrintEventArgs.HasMorePages property to true,
which causes the PrintPage event to fire again. Because the
PrintPage event handler retains no inherent memory of
how many pages have been printed, you must incorporate
all logic for printing multiple pages into your event handler.
96.Explain how to use the Begin and End methods on a
Web Service to make an asynchronous method call.
Every public Web method on a Web Service can be called
either synchronously or asynchronously. To make an
asynchronous call to a Web method, you call the method
named Begin<webmethod>, where <webmethod> is the
name of the method. This method requires a delegate to an
appropriate callback method and returns a value of
IAsyncResult. This value is returned as a parameter in the
callback method. To retrieve the data returned by the Web
method, call End<webmethod>, supplying a reference to
the IAsyncResult returned by Begin<webmethod>. This
will allow you to retrieve the actual data returned by the
Web method.
97.Briefly describe the five accessibility requirements of
the Certified for Windows logo program.
The five requirements are
o Support standard system settings. This requires your
application to be able to conform to system settings
for colors, fonts, and other UI elements.
o Be compatible with High Contrast mode. This
requirement can be met by using only the System
palette for UI colors.
o Provide documented keyboard access for all UI
features. Key points in this requirement are shortcut
keys and accessible documentation.
o Provide notification of the focus location. This
requirement is handled primarily by the .NET
Framework.
o Convey no information by sound alone. This
requirement can be met by providing redundant means
of conveying information.
98.Explain how to use the HelpProvider component to
provide help for UI elements.
You can provide either a HelpString or a help topic for UI
elements with the HelpProvider. The HelpProvider
provides HelpString, HelpKeyWord, and HelpNavigator
properties for each control on the form. If no value for the
HelpProvider.HelpNameSpace is set, the HelpString will
be provided as help. If the HelpNameSpace is set, the
HelpProvider will display the appropriate help topic as
configured by the HelpKeyWord and HelpNavigator
properties. Help for a particular element is displayed when
the element has the focus and the F1 key is pressed.
99.Describe how to create localized versions of a form.
To create a localized version of a form, set the Localizable
property to true. Then set the Language property to the
language/region for which you want to create the localized
form. Make any localization-related changes in the UI. The
changed property values will automatically be stored in
resource files and loaded when the CurrentUICulture is set
to the appropriate CultureInfo.
100.Explain how to convert data in legacy code page
formats to the Unicode format.
You can use the Encoding.Convert method to convert data
between encoding types. This method requires instances of
both encoding types and an array of bytes that represents
the data to be converted. It returns an array of bytes in the
target format. You can convert a string or array of chars to
an array of bytes with the Encoding.GetBytes method and
can convert an array of bytes back to chars with the
Encoding.GetChars method.
101.Explain the difference between Globalization and
Localization.
Globalization refers to the application of culture-specific
format to existing data. Localization refers to providing
new culture-specific resources and retrieving the
appropriate resources based on the culture setting
102.Describe how to sign your assembly with a strong
name. Why would you want to do this?
To sign your assembly with a strong name, you must have
access to a key file or create one with the strong name
utility (sn.exe). You then specify the key file in the
AssemblyInfo file and verify that the version number is
correct. The assembly will be signed with a strong name
when built. In addition to identifying your assembly and
ensuring version identity, a strong name is required if you
want to install your assembly to the Global Assembly
Cache.
103.Describe how to use code to retrieve resources at run
time.
You must first create an instance of the ResourceManager
class that is associated with the assembly that contains the
desired resource. You can then use the GetString method to
retrieve string resources or the GetObject method to
retrieve object resources.
104.Explain how to retrieve information from the
configuration file at run time. How would you store
information in the configuration file at design time?
You must first create an instance of AppSettingsReader to
read the configuration file. You can then call the GetValue
method to read values represented in the configuration file.
To add configuration file entries, you should create <add>
elements in the <appSettings> node of the configuration
file. In the <add> element, you should specify a value for
the entry and a key that can be used to retrieve the entry.
The value can be changed between executions of the
application.
105.You are creating a solution that must be accessed by
members of a group called Developers and Administrators
on the local machine. Describe a plan to implement this
security scheme.
Create one PrincipalPermission that represents the
Developers group and another PrincipalPermission that
represents the BUILTIN\Administrators group. Then, create
a third permission that represents the union of the two by
calling the Union method and demand that permission.
106.Briefly highlight the differences between imperative
and declarative security as they pertain to code access
security.
Imperative security is implemented by calling methods of
Permission objects in code at run time. Declarative security
is configured by attaching attributes representing
permissions to classes and methods. Imperative security
allows a finer control over the point in execution where
permissions are demanded, but declarative security is
emitted into metadata, and required permissions can be
discovered through the classes in the System.Reflection
namespace. Additionally, you can request assembly-wide
permissions using the Assembly (assembly) directive with
declarative security.
107.Describe XCOPY deployment. Under what conditions
is it useful? When can it not be used?
XCOPY deployment is a simple method of deployment
where the DOS command XCOPY is used to copy the
application directory and any subdirectories to the target
machine. You can use XCOPY deployment if your
application has no dependency on shared files and requires
no special actions to be taken upon deployment. If an
application requires a more complex deployment or
references shared assemblies, you cannot use XCOPY.
108.You have written documentation for your application
and have provided it in the form of several HTML files.
Describe two ways you could include this content in your
setup project.
You can include loose HTML files along with your
application by either including them when you create the
setup project with the Setup wizard or by adding them to
the project after creation with the File System Editor.
109.What is a native image? How do you create one?
A native image is a precompiled version of a .NET
assembly. You can create a native image of your application
by using the Ngen.exe utility.
110.What is the purpose of a bootstrapper application?
When do you not need to create one?
A bootstrapper application automatically detects if
Windows Installer is installed on the target machine. If
Windows Installer is not present, it installs Windows
Installer before proceeding with the rest of the installation.
You should create a bootstrapper application unless all of
your target machines are running Windows XP (which has
Microsoft Windows Installer 1.5 already installed) or have
had Microsoft Installer 1.5 installed previously.
111.What is a Destructor ?
Ans : A destructor is a member that implements the actions
required to destruct an instance of a class. Destructors cannot
have parameters, cannot have accessibility modifiers, and cannot
be called explicitly. The destructor for an instance is called
automatically during garbage collection.
112.What is a instance constructor?
Ans : An instance constructor is a member that implements the
actions required to initialize an instance of a class.
113.What is a Static Constructor?
A static constructor is used to initialize a class and is called
automatically to initialize the class before the static members are
accessed.
A static constructor is only called once throughout the
application's lifetime. The static constructor method is called
when any of the defining class' members are first accessed. The
constructor is called once only
cannot have parameters,
cannot have accessibility modifiers,
and cannot be called explicitly.
The static constructor for a class is called automatically.
114.What is static Readonly fields ?
Ans : Static fields are not a perfect match for this scenario. The
fields are initialized at some point before they are used, but after
this initialization there is nothing to stop a client from changing
them. Such a modification could cause unpredictable errors in
other programs that use Color and assume that the values do not
change. Readonly fields can be used to prevent such problems.
Assignments to a readonly field can only occur as part of the
declaration,
or in an instance or static constructor in the same class.
A static readonly field can be assigned in a static constructor,
and a non-static readonly field can be assigned in an instance
constructor.
115.What is a constant?
Ans : A constant is a class member that represents a constant
value:
a value that can be computed at compile-time.
Constants are permitted to depend on other constants within the
same program as long as there are no circular dependencies.
116.What is a method?
Ans : A method is a member that implements a computation or
action that can be performed by an object or class. Methods
have a list of formal parameters (which may be empty), a return
value (or void), and are either static or non-static.
Static methods are accessed through the class.
Non-static methods, which are also called instance methods, are
accessed through instances of the class.
Methods can be overloaded, which means that multiple methods
may have the same name so long as they have unique
signatures.
The signature of a method consists of the name of the method
and the number, modifiers, and types of its formal parameters.
The signature of a method does not include the return type.
117.What is a Property ?
Ans : A property is a member that provides access to a
characteristic
of an object or a class.
Examples of properties include the length of a string, the size of
a font,
the caption of a window, the name of a customer, and so on.
Properties are a natural extension of fields.
Both are named members with associated types, and the syntax
for accessing fields and properties is the same. However, unlike
fields, properties do not denote storage locations.
Instead, properties have accessors that specify the statements to
be executed when their values are read or written.
118.What r delegates and events?
Ans : It suffices to simply state that a delegate is the object-
oriented (and type-safe) equivalent of a function pointer.
A delegate instance holds a reference to an instance or class
method, permitting anonymous invocation of the bound method.
Events are special constructs declared on a class that help to
expose state changes to interested objects at run time.
An event represents a formal abstraction (supported by the CLR
and various compilers)
of the registration, unregistration, and notification methods we
used previously to implement the Observer pattern.
Delegates are registered with specific events at run time.
When the event is raised, all registered delegates are invoked so
that they receive notification of the event.
119. What is the difference between Value types and Object
types?
A. Value types are built-in data types in any .Net compliant
language and they are stored on the application stack, whereas
the Object types are user-defined types and are by default
reference types and will be stored in the managed heap.
120. When is a value type used over an object type?
A. Value types are used for temporary storage. They are valid
only in the scope of the function or the execution block in which
they are declared. Whereas the reference types are used for user-
defined types which need to retain the state across function calls
and have a lifetime which is defined by the usage.
121. Given an unsigned 16 bit integer, what is the max value
it can hold?
A. 65535
122. What happens if I store more than max value in the
previous scenario?
A. In .Net this scenario can be addressed in two ways: If the
same is done in a checked context, the runtime will throw an
OverflowException, whereas if run in unchecked context, the
MSB is truncated and rest of the value is stored in the variable
and the execution continues…
123. What does the new keyword do w.r.t inheritance?
A. It hides the base class’s implementation.
124. Rate yourself in OOAD and UML on a scale of 10?
A. 7-8.
125. What is the difference between Inheritance and
Composition?
A. Inheritance is a generalization relationship, used for code
reuse. I cited an example of Shape as the base class and Circle,
Rectangle as the derived classes. Explained him about
generalization to specialization.
Composition is a strong form of containment, where the part’s
lifetime is dependent on the whole.
126. What is polymorphism?
A. Compile time polymorphism (Function/operator overloading
examples).
Runtime polymorphism (Late binding, Virtual/Overridden
functions examples).
127. What all database components are available in .NET?
A. ADO.NET components. Connection, Command, DataReader,
DataSet and DataView. Explained each.
128. What is the advantage of using the OLE DB drivers
directly?
A. Certainly the performance will improve as the abstraction
layers are removed.
129. What is the difference between a clustered index and
non-clustered index?
A. In a clustered-index, the data page and the index page are
same whereas in a non-clustered index, the data pages and the
index page is separate.
130. Explain a Left outer join and a right outer join?
A. Left outer join will also involve the fields of the table on the
left of the join query that are not specified in the SQL query.
Right outer join will also involve the fields of the table on the
right of the join query that are not specified in the SQL query.
131. Do you know about execution plan?
A. Execution plans are formed by the database engine to find the
optimized way of executing a query.
132.What is the difference between process and thread?
Ans: Process is a program in execution whereas thread is a
separate path of execution in a program.
133.What is multithreading and what are the methods for
inter-thread communication and what is the class in which
these methods are defined?
Ans: Multithreading is the mechanism in which more than one
thread run independent of each other within the process.
wait (), notify () and notifyAll() methods can be used for inter-
thread communication and these methods are in Object class.
wait( ) : When a thread executes a call to wait( ) method, it
surrenders the object lock and enters into a waiting state.
notify( ) or notifyAll( ) : To remove a thread from the waiting
state, some other thread must make a call to notify( ) or
notifyAll( ) method on the same object.
134.What is the class and interface in java to create thread
and which is the most advantageous method?
Ans: Thread class and Runnable interface can be used to create
threads and using Runnable interface is the most advantageous
method to create threads because we need not extend thread
class here.
135.What are the states associated in the thread?
Ans: Thread contains ready, running, waiting and dead states.
136.What is synchronization?
Ans: Synchronization is the mechanism that ensures that only
one thread is accessed the resources at a time.
137.When you will synchronize a piece of your code?
Ans: When you expect your code will be accessed by different
threads and these threads may change a particular data causing
data corruption.
138.What is deadlock?
Ans: When two threads are waiting each other and can’t precede
the program is said to be deadlock.
139.What is daemon thread and which method is used to
create the daemon thread?
Ans: Daemon thread is a low priority thread which runs
intermittently in the back ground doing the garbage collection
operation for the java runtime system. setDaemon method is
used to create a daemon thread.
140. What is runnable?.
Its an Interface through which Java implements Threads.The
class can extend from any class but if it implements
Runnable,Threads can be used in that particular application.
141. What is preemptive and Non-preemptive Time
Scheduling?.
Preemptive: Running tasks are given small portions of time to
execute by using time-slicing.
Non-Preemptive: One task doesn’t give another task a chance to
run until its finished or has normally yielded its time.
142. What is synchronization?.
Two or more threads trying to access the same method at the
same point of time leads to synchronization.If that particular
method is declared as synchronized only one thread can access it
at a time. Another thread can access it only if the first thread’s
task is complete.
143. What are the various thread priorities?.
(i) Min-Priority-value(1).
(ii) Normal-Priority-value(5).
(iii)Max-Priority-value(10).

144.What is Inter-Thread communication?.


To exchange information between two threads.

145. What is the superclass of exception?.


Throwable.
146. What is the return type of interrupt method?.
void.
147.Why do threads block on I/O?
Threads block on i/o (that is enters the waiting state) so that
other threads
may execute while the i/o
Operation is performed.
148. What is synchronization and why is it important?
With respect to multithreading, synchronization is the capability
to control the access of multiple threads to shared resources.
Without synchronization, it is possible for one thread to modify
a shared object while another thread is in the process of using or
updating that object’s value. This often leads to significant
errors.
149. Can a lock be acquired on a class?
Yes, a lock can be acquired on a class. This lock is acquired on
the class’s Class object.
150. What’s new with the stop(), suspend() and resume()
methods in JDK 1.2?
The stop(), suspend() and resume() methods have been
deprecated in JDK 1.2.
151. What state does a thread enter when it terminates its
processing?
When a thread terminates its processing, it enters the dead state.
152.What is the difference between yielding and sleeping?
When a task invokes its yield() method, it returns to the ready
state. When a task invokes its sleep() method, it returns to the
waiting state.
153. What is the difference between preemptive scheduling
and time slicing?
Under preemptive scheduling, the highest priority task executes
until it enters the waiting or dead states or a higher priority task
comes into existence.Under time slicing, a task executes for a
predefined slice of time and thenreenters the pool of ready tasks.
The scheduler then determines which task should execute next,
based on priority and other factors.
154. When a thread blocks on I/O, what state does it enter?
A thread enters the waiting state when it blocks on I/O.
155. What is a task’s priority and how is it used in
scheduling?
A task’s priority is an integer value that identifies the relative
order in which it should be executed with respect to other tasks.
The scheduler attempts to schedule higher priority tasks before
lower priority tasks.
156. When a thread is created and started, what is its initial
state?
A thread is in the ready state after it has been created and started.
157. What invokes a thread’s run() method?
After a thread is started, via its start() method or that of the
Thread class, the JVM invokes the thread’s run() method when
the thread is initially executed.
158. What method is invoked to cause an object to begin
executing as a separate thread?
The start() method of the Thread class is invoked to cause an
object to begin executing as a separate thread.
159. What is the purpose of the wait(), notify(), and
notifyAll() methods?
The wait(),notify(), and notifyAll() methods are used to provide
an efficient way for threads to wait for a shared resource. When
a thread executes an object’s wait() method, it enters the waiting
state. It only enters the ready state after another thread invokes
the object’s notify() or notifyAll() methods.
160. What are the high-level thread states?
The high-level thread states are ready, running, waiting, and
dead.
161. What is an object’s lock and which object’s have locks?
An object’s lock is a mechanism that is used by multiple threads
to obtain synchronized access to the object. A thread may
execute a synchronized method of an object only after it has
acquired the object’s lock. All objects and classes have locks. A
class’s lock is acquired on the class’s Class object.
162. What happens when a thread cannot acquire a lock on
an object?
If a thread attempts to execute a synchronized method or
synchronized statement and is unable to acquire an object’s lock,
it enters the waiting state until the lock becomes available.
163. What happens when you invoke a thread’s interrupt
method while it is sleeping or waiting?
When a task’s interrupt() method is executed, the task enters the
ready state. The next time the task enters the running state, an
InterruptedException is thrown.
164. What state is a thread in when it is executing?
An executing thread is in the running state.
165. How can a dead thread be restarted?
A dead thread cannot be restarted.
166. What are three ways in which a thread can enter the
waiting state?
A thread can enter the waiting state by invoking its sleep()
method, by blocking on I/O, by unsuccessfully attempting to
acquire an object’s lock, or by invoking an object’s wait()
method. It can also enter the waiting state by invoking its
(deprecated) suspend() method.
167. What method must be implemented by all threads?
All tasks must implement the run() method, whether they are a
subclass of Thread or implement the Runnable interface.
168. What are synchronized methods and synchronized
statements?
Synchronized methods are methods that are used to control
access to an object. A thread only executes a synchronized
method after it has acquired the lock for the method’s object or
class. Synchronized statements are similar to synchronized
methods. A synchronized statement can only be executed after a
thread has acquired the lock for the object or class referenced in
the synchronized statement.
169. What are the two basic ways in which classes that can
be run as threads may be defined?
A thread class may be declared as a subclass of Thread, or it
may implement the Runnable interface.
170. What is .NET?
.NET is a general-purpose software development platform,
similar to Java. At its core is a virtual machine that turns
intermediate language (IL) into machine code. High-level
language compilers for C#, VB.NET and C++ are provided to
turn source code into IL. C# is a new programming language,
very similar to Java. An extensive class library is included,
featuring all the functionality one might expect from a
contempory development platform - windows GUI development
(Windows Forms), database access (ADO.NET), web
development (ASP.NET), web services, XML etc.
171. When was .NET announced?
Bill Gates delivered a keynote at Forum 2000, held June 22,
2000, outlining the .NET 'vision'. The July 2000 PDC had a
number of sessions on .NET technology, and delegates were
given CDs containing a pre-release version of the .NET
framework/SDK and Visual Studio.NET.
172. What versions of .NET are there?
The final version of the 1.0 SDK and runtime was made publicly
available around 6pm PST on 15-Jan-2002. At the same time,
the final version of Visual Studio.NET was made available to
MSDN subscribers.
.NET 1.1 was released in April 2003 - it's mostly bug fixes for
1.0.
.NET 2.0 is expected in 2005.
173. What operating systems does the .NET Framework run
on?
The runtime supports Windows Server 2003, Windows XP,
Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is
not supported. Some parts of the framework do not work on all
platforms - for example, ASP.NET is only supported on XP and
Windows 2000/2003. Windows 98/ME cannot be used for
development.
IIS is not supported on Windows XP Home Edition, and so
cannot be used to host ASP.NET. However, the ASP.NET Web
Matrix web server does run on XP Home.
The .NET Compact Framework is a version of the .NET
Framework for mobile devices, running Windows CE or
Windows Mobile.
The Mono project has a version of the .NET Framework that
runs on Linux.
174. What tools can I use to develop .NET applications?
There are a number of tools, described here in ascending order
of cost:
• The .NET Framework SDK is free and includes command-
line compilers for C++, C#, and VB.NET and various other
utilities to aid development.
• ASP.NET Web Matrix is a free ASP.NET development
environment from Microsoft. As well as a GUI
development environment, the download includes a simple
web server that can be used instead of IIS to host ASP.NET
apps. This opens up ASP.NET development to users of
Windows XP Home Edition, which cannot run IIS.
• Microsoft Visual C# .NET Standard 2003 is a cheap
(around $100) version of Visual Studio limited to one
language and also with limited wizard support. For
example, there's no wizard support for class libraries or
custom UI controls. Useful for beginners to learn with, or
for savvy developers who can work around the deficiencies
in the supplied wizards. As well as C#, there are VB.NET
and C++ versions.
• Microsoft Visual Studio.NET Professional 2003. If you
have a license for Visual Studio 6.0, you can get the
upgrade. You can also upgrade from VS.NET 2002 for a
token $30. Visual Studio.NET includes support for all the
MS languages (C#, C++, VB.NET) and has extensive
wizard support.
At the top end of the price spectrum are the Visual Studio.NET
2003 Enterprise and Enterprise Architect editions. These offer
extra features such as Visual Sourcesafe (version control), and
performance and analysis tools. Check out the Visual
Studio.NET Feature Comparison at
http://msdn.microsoft.com/vstudio/howtobuy/choosing.asp
175. Why did they call it .NET?
I don't know what they were thinking. They certainly weren't
thinking of people using search tools. It's meaningless marketing
nonsense - best not to think about it.
176. What is the CLI? Is it the same as the CLR?
The CLI (Common Language Infrastructure) is the definiton of
the fundamentals of the .NET framework - the Common Type
System (CTS), metadata, the Virtual Execution Environment
(VES) and its use of intermediate language (IL), and the support
of multiple programming languages via the Common Language
Specification (CLS). The CLI is documented through ECMA -
see http://msdn.microsoft.com/net/ecma/ for more details.
The CLR (Common Language Runtime) is Microsoft's primary
implementation of the CLI. Microsoft also have a shared source
implementation known as ROTOR, for educational purposes, as
well as the .NET Compact Framework for mobile devices. Non-
Microsoft CLI implementations include Mono and DotGNU
Portable.NET.
177. What is the CTS, and how does it relate to the CLS?
CTS = Common Type System. This is the full range of types that
the .NET runtime understands. Not all .NET languages support
all the types in the CTS.
CLS = Common Language Specification. This is a subset of the
CTS which all .NET languages are expected to support. The idea
is that any program which uses CLS-compliant types can
interoperate with any .NET program written in any language. This
interop is very fine-grained - for example a VB.NET class can
inherit from a C# class.
178. What is IL?
IL = Intermediate Language. Also known as MSIL (Microsoft
Intermediate Language) or CIL (Common Intermediate
Language). All .NET source code (of any language) is compiled
to IL during development. The IL is then converted to machine
code at the point where the software is installed, or (more
commonly) at run-time by a Just-In-Time (JIT) compiler.
179.What does 'managed' mean in the .NET context?
The term 'managed' is the cause of much confusion. It is used in
various places within .NET, meaning slightly different things.
Managed code: The .NET framework provides several core run-
time services to the programs that run within it - for example
exception handling and security. For these services to work, the
code must provide a minimum level of information to the
runtime. Such code is called managed code.
Managed data: This is data that is allocated and freed by the
.NET runtime's garbage collector.
Managed classes: This is usually referred to in the context of
Managed Extensions (ME) for C++. When using ME C++, a
class can be marked with the __gc keyword. As the name
suggests, this means that the memory for instances of the class is
managed by the garbage collector, but it also means more than
that. The class becomes a fully paid-up member of the .NET
community with the benefits and restrictions that brings. An
example of a benefit is proper interop with classes written in
other languages - for example, a managed C++ class can inherit
from a VB class. An example of a restriction is that a managed
class can only inherit from one base class.
180. What is reflection?
All .NET compilers produce metadata about the types defined in
the modules they produce. This metadata is packaged along with
the module (modules in turn are packaged together in
assemblies), and can be accessed by a mechanism called
reflection. The System.Reflection namespace contains classes
that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to
using ITypeLib/ITypeInfo to access type library data in COM,
and it is used for similar purposes - e.g. determining data type
sizes for marshaling data across context/process/machine
boundaries.
Reflection can also be used to dynamically invoke methods (see
System.Type.InvokeMember), or even create types dynamically
at run-time (see System.Reflection.Emit.TypeBuilder).
181. What is an assembly?
An assembly is sometimes described as a logical .EXE or .DLL,
and can be an application (with a main entry point) or a library.
An assembly consists of one or more files (dlls, exes, html files
etc), and represents a group of resources, type definitions, and
implementations of those types. An assembly may also contain
references to other assemblies. These resources, types and
references are described in a block of data called a manifest. The
manifest is part of the assembly, thus making the assembly self-
describing.
An important aspect of assemblies is that they are part of the
identity of a type. The identity of a type is the assembly that
houses it combined with the type name. This means, for
example, that if assembly A exports a type called T, and
assembly B exports a type called T, the .NET runtime sees these
as two completely different types. Furthermore, don't get
confused between assemblies and namespaces - namespaces are
merely a hierarchical way of organising type names. To the
runtime, type names are type names, regardless of whether
namespaces are used to organise the names. It's the assembly
plus the typename (regardless of whether the type name belongs
to a namespace) that uniquely indentifies a type to the runtime.
Assemblies are also important in .NET with respect to security -
many of the security restrictions are enforced at the assembly
boundary.
Finally, assemblies are the unit of versioning in .NET - more on
this below.
182. How can I produce an assembly?
The simplest way to produce an assembly is directly from a
.NET compiler. For example, the following C# program:
public class Ctest {public CTest()
{ System.Console.WriteLine( "Hello from CTest" ); } }
can be compiled into a library assembly (dll) like this:
csc /t:library ctest.cs
You can then view the contents of the assembly by running the
"IL Disassembler" tool that comes with the .NET SDK.
Alternatively you can compile your source into modules, and
then combine the modules into an assembly using the assembly
linker (al.exe). For the C# compiler, the /target:module switch is
used to generate a module instead of an assembly.
183. What is the difference between a private assembly and a
shared assembly?
• Location and visibility: A private assembly is normally

used by a single application, and is stored in the


application's directory, or a sub-directory beneath. A shared
assembly is normally stored in the global assembly cache,
which is a repository of assemblies maintained by the .NET
runtime. Shared assemblies are usually libraries of code
which many applications will find useful, e.g. the .NET
framework classes.
• Versioning: The runtime enforces versioning constraints

only on shared assemblies, not on private assemblies.


184. How do assemblies find each other?
By searching directory paths. There are several factors which
can affect the path (such as the AppDomain host, and
application configuration files), but for private assemblies the
search path is normally the application's directory and its sub-
directories. For shared assemblies, the search path is normally
same as the private assembly path plus the shared assembly
cache.
185. How does assembly versioning work?
Each assembly has a version number called the compatibility
version. Also each reference to an assembly (from another
assembly) includes both the name and version of the referenced
assembly.
The version number has four numeric parts (e.g. 5.5.2.33).
Assemblies with either of the first two parts different are
normally viewed as incompatible. If the first two parts are the
same, but the third is different, the assemblies are deemed as
'maybe compatible'. If only the fourth part is different, the
assemblies are deemed compatible. However, this is just the
default guideline - it is the version policy that decides to what
extent these rules are enforced. The version policy can be
specified via the application configuration file.
Remember: versioning is only applied to shared assemblies, not
private assemblies.
186. Can I write my own .NET host?
Yes. For an example of how to do this, take a look at the source
for the dm.net moniker developed by Jason Whittington and
Don Box. There is also a code sample in the .NET SDK called
CorHost.
187. What is garbage collection?
Garbage collection is a heap-management strategy where a run-
time component takes responsibility for managing the lifetime of
the memory used by objects. This concept is not new to .NET -
Java and many other languages/runtimes have used garbage
collection for some time.
188. Is it true that objects don't always get destroyed
immediately when the last reference goes away?
Yes. The garbage collector offers no guarantees about the time
when an object will be destroyed and its memory reclaimed.
189. Why doesn't the .NET runtime offer deterministic
destruction?
Because of the garbage collection algorithm. The .NET garbage
collector works by periodically running through a list of all the
objects that are currently being referenced by an application. All
the objects that it doesn't find during this search are ready to be
destroyed and the memory reclaimed. The implication of this
algorithm is that the runtime doesn't get notified immediately
when the final reference on an object goes away - it only finds
out during the next 'sweep' of the heap.
Futhermore, this type of algorithm works best by performing the
garbage collection sweep as rarely as possible. Normally heap
exhaustion is the trigger for a collection sweep.
190. Is the lack of deterministic destruction in .NET a
problem?
It's certainly an issue that affects component design. If you have
objects that maintain expensive or scarce resources (e.g.
database locks), you need to provide some way to tell the object
to release the resource when it is done. Microsoft recommend
that you provide a method called Dispose() for this purpose.
However, this causes problems for distributed objects - in a
distributed system who calls the Dispose() method? Some form
of reference-counting or ownership-management mechanism is
needed to handle distributed objects - unfortunately the runtime
offers no help with this.
191. Do I have any control over the garbage collection
algorithm?
A little. For example the System.GC class exposes a Collect
method, which forces the garbage collector to collect all
unreferenced objects immediately.
Also there is a gcConcurrent setting that can be specified via
the application configuration file. This specifies whether or not
the garbage collector performs some of its collection activities
on a separate thread. The setting only applies on multi-processor
machines, and defaults to true.
192. How can I find out what the garbage collector is doing?
Lots of interesting statistics are exported from the .NET runtime
via the '.NET CLR xxx' performance counters. Use Performance
Monitor to view them.
193. What is the lapsed listener problem?
The lapsed listener problem is one of the primary causes of leaks
in .NET applications. It occurs when a subscriber (or 'listener')
signs up for a publisher's event, but fails to unsubscribe. The
failure to unsubscribe means that the publisher maintains a
reference to the subscriber as long as the publisher is alive. For
some publishers, this may be the duration of the application.
This situation causes two problems. The obvious problem is the
leakage of the subscriber object. The other problem is the
performance degredation due to the publisher sending redundant
notifications to 'zombie' subscribers.
There are at least a couple of solutions to the problem. The
simplest is to make sure the subscriber is unsubscribed from the
publisher, typically by adding an Unsubscribe() method to the
subscriber. Another solution, documented here by Shawn Van
Ness, is to change the publisher to use weak references in its
subscriber list.
194. When do I need to use GC.KeepAlive?
It's very unintuitive, but the runtime can decide that an object is
garbage much sooner than you expect. More specifically, an
object can become garbage while a method is executing on the
object, which is contrary to most developers' expectations. Chris
Brumme explains the issue on his blog. I've taken Chris's code
and expanded it into a full app that you can play with if you
want to prove to yourself that this is a real problem:
195. What is serialization?
Serialization is the process of converting an object into a stream
of bytes. Deserialization is the opposite process, i.e. creating an
object from a stream of bytes. Serialization/Deserialization is
mostly used to transport objects (e.g. during remoting), or to
persist objects (e.g. to a file or database).
196. Does the .NET Framework have in-built support for
serialization?
There are two separate mechanisms provided by the .NET class
library - XmlSerializer and SoapFormatter/BinaryFormatter.
Microsoft uses XmlSerializer for Web Services and
SoapFormatter/BinaryFormatter for remoting. Both are available
for use in your own code.
197. I want to serialize instances of my class. Should I use
XmlSerializer, SoapFormatter or BinaryFormatter?
It depends. XmlSerializer has severe limitations such as the
requirement that the target class has a parameterless constructor,
and only public read/write properties and fields can be
serialized. However, on the plus side, XmlSerializer has good
support for customising the XML document that is produced or
consumed. XmlSerializer's features mean that it is most suitable
for cross-platform work, or for constructing objects from
existing XML documents.
SoapFormatter and BinaryFormatter have fewer limitations than
XmlSerializer. They can serialize private fields, for example.
However they both require that the target class be marked with
the [Serializable] attribute, so like XmlSerializer the class needs
to be written with serialization in mind. Also there are some
quirks to watch out for - for example on deserialization the
constructor of the new object is not invoked.
The choice between SoapFormatter and BinaryFormatter
depends on the application. BinaryFormatter makes sense where
both serialization and deserialization will be performed on the
.NET platform and where performance is important.
SoapFormatter generally makes more sense in all other cases,
for ease of debugging if nothing else.
198. Can I customise the serialization process?
Yes. XmlSerializer supports a range of attributes that can be
used to configure serialization for a particular class. For
example, a field or property can be marked with the
[XmlIgnore] attribute to exclude it from serialization. Another
example is the [XmlElement] attribute, which can be used to
specify the XML element name to be used for a particular
property or field.
Serialization via SoapFormatter/BinaryFormatter can also be
controlled to some extent by attributes. For example, the
[NonSerialized] attribute is the equivalent of XmlSerializer's
[XmlIgnore] attribute. Ultimate control of the serialization
process can be acheived by implementing the the ISerializable
interface on the class whose instances are to be serialized.
199. Why is XmlSerializer so slow?
There is a once-per-process-per-type overhead with
XmlSerializer. So the first time you serialize or deserialize an
object of a given type in an application, there is a significant
delay. This normally doesn't matter, but it may mean, for
example, that XmlSerializer is a poor choice for loading
configuration settings during startup of a GUI application.
200. Why do I get errors when I try to serialize a Hashtable?
XmlSerializer will refuse to serialize instances of any class that
implements IDictionary, e.g. Hashtable. SoapFormatter and
BinaryFormatter do not have this restriction.
201. What are attributes?
There are at least two types of .NET attribute. The first type I
will refer to as a metadata attribute - it allows some data to be
attached to a class or method. This data becomes part of the
metadata for the class, and (like other class metadata) can be
accessed via reflection. An example of a metadata attribute is
[serializable], which can be attached to a class and means that
instances of the class can be serialized.
[serializable] public class CTest {}
The other type of attribute is a context attribute. Context
attributes use a similar syntax to metadata attributes but they are
fundamentally different. Context attributes provide an
interception mechanism whereby instance activation and method
calls can be pre- and/or post-processed. If you have encountered
Keith Brown's universal delegator you'll be familiar with this
idea.
202. What is Code Access Security (CAS)?
CAS is the part of the .NET security model that determines
whether or not code is allowed to run, and what resources it can
use when it is running. For example, it is CAS that will prevent
a .NET web applet from formatting your hard disk.
203. How does CAS work?
The CAS security policy revolves around two key concepts -
code groups and permissions. Each .NET assembly is a member
of a particular code group, and each code group is granted the
permissions specified in a named permission set.
For example, using the default security policy, a control
downloaded from a web site belongs to the 'Zone - Internet'
code group, which adheres to the permissions defined by
the 'Internet' named permission set. (Naturally the 'Internet'
named permission set represents a very restrictive range of
permissions.)
204. Can I look at the IL for an assembly?
Yes. MS supply a tool called Ildasm that can be used to view the
metadata and IL for an assembly.
205. Can source code be reverse-engineered from IL?
Yes, it is often relatively straightforward to regenerate high-level
source from IL. Lutz Roeder's Reflector does a very good job of
turning IL into C# or VB.NET.
206. How can I stop my code being reverse-engineered from
IL?
You can buy an IL obfuscation tool. These tools work by
'optimising' the IL in such a way that reverse-engineering
becomes much more difficult.
Of course if you are writing web services then reverse-
engineering is not a problem as clients do not have access to
your IL.
207. Is COM+ dead?
Not immediately. The approach for .NET 1.0 was to provide
access to the existing COM+ services (through an interop layer)
rather than replace the services with native .NET ones. Various
tools and attributes were provided to make this as painless as
possible. Over time it is expected that interop will become more
seamless - this may mean that some services become a core part
of the CLR, and/or it may mean that some services will be
rewritten as managed code which runs on top of the CLR.
208. Can I use COM components from .NET programs?
Yes. COM components are accessed from the .NET runtime via
a Runtime Callable Wrapper (RCW). This wrapper turns the
COM interfaces exposed by the COM component into .NET-
compatible interfaces. For oleautomation interfaces, the RCW
can be generated automatically from a type library. For non-
oleautomation interfaces, it may be necessary to develop a
custom RCW which manually maps the types exposed by the
COM interface to .NET-compatible types.
209.Can I use .NET components from COM programs?
Yes. .NET components are accessed from COM via a COM
Callable Wrapper (CCW). This is similar to a RCW (see
previous question), but works in the opposite direction.
Again, if the wrapper cannot be automatically generated by
the .NET development tools, or if the automatic behaviour
is not desirable, a custom CCW can be developed. Also, for
COM to 'see' the .NET component, the .NET component
must be registered in the registry.
210. How does .NET remoting work?
.NET remoting involves sending messages along channels. Two
of the standard channels are HTTP and TCP. TCP is intended for
LANs only - HTTP can be used for LANs or WANs (internet).
Support is provided for multiple message serializarion formats.
Examples are SOAP (XML-based) and binary. By default, the
HTTP channel uses SOAP (via the .NET runtime Serialization
SOAP Formatter), and the TCP channel uses binary (via the
.NET runtime Serialization Binary Formatter). But either
channel can use either serialization format.
There are a number of styles of remote access:
• SingleCall. Each incoming request from a client is serviced
by a new object. The object is thrown away when the
request has finished.
• Singleton. All incoming requests from clients are processed
by a single server object.
• Client-activated object. This is the old stateful (D)COM
model whereby the client receives a reference to the remote
object and holds that reference (thus keeping the remote
object alive) until it is finished with it.
Distributed garbage collection of objects is managed by a
system called 'leased based lifetime'. Each object has a lease
time, and when that time expires the object is disconnected from
the .NET runtime remoting infrastructure. Objects have a default
renew time - the lease is renewed when a successful call is made
from the client to the object. The client can also explicitly renew
the lease.
If you're interested in using XML-RPC as an alternative to
SOAP, take a look at Charles Cook's XML-RPC.Net.
211. How can I get at the Win32 API from a .NET program?
Use P/Invoke. This uses similar technology to COM
Interop, but is used to access static DLL entry points
instead of COM objects.
212. What is the difference between an event and a delegate?
An event is just a wrapper for a multicast delegate. Adding a
public event to a class is almost the same as adding a public
multicast delegate field. In both cases, subscriber objects can
register for notifications, and in both cases the publisher object
can send notifications to the subscribers. However, a public
multicast delegate has the undesirable property that external
objects can invoke the delegate, something we'd normally want
to restrict to the publisher. Hence events - an event adds public
methods to the containing class to add and remove receivers, but
does not make the invocation mechanism public.
213. What size is a .NET object?
Each instance of a reference type has two fields maintained
by the runtime - a method table pointer and a sync block.
These are 4 bytes each on a 32-bit system, making a total of
8 bytes per object overhead. Obviously the instance data for
the type must be added to this to get the overall size of the
object
214. What are the new features of .NET 2.0?
Generics, anonymous methods, partial classes, iterators,
property visibility (separate visibility for get and set) and static
classes.
215. What are the new 2.0 features useful for?
Generics are useful for writing efficient type-independent
code, particularly where the types might include value
types. The obvious application is container classes, and the
.NET 2.0 class library includes a suite of generic container
classes in the System.Collections.Generic namespace.
216. What's the problem with .NET generics?
.NET generics work great for container classes. But what
about other uses? Well, it turns out that .NET generics have
a major limitation - they require the type parameter to be
constrained.
217. What's new in the .NET 2.0 class library?
Here is a selection of new features in the .NET 2.0 class library
(beta 1):
• Generic collections in the System.Collections.Generic
namespace.
• The System.Nullable<T> type. (Note that C# has special
syntax for this type, e.g. int? is equivalent to Nullable<int>)
• The GZipStream and DeflateStream classes in the
System.IO.Compression namespace.
• The Semaphore class in the System.Threading namespace.
• Wrappers for DPAPI in the form of the ProtectedData and
ProtectedMemory classes in the
System.Security.Cryptography namespace.
• The IPC remoting channel in the
System.Runtime.Remoting.Channels.Ipc namespace, for
optimised intra-machine communication.
218.What is the .NET Framework?
The Microsoft .NET Framework is a platform for building,
deploying, and running Web Services and applications. It
provides a highly productive, standards-based, multi-language
environment for integrating existing investments with next-
generation applications and services as well as the agility to
solve the challenges of deployment and operation of Internet-
scale applications. The .NET Framework consists of three main
parts: the common language runtime, a hierarchical set of
unified class libraries, and a componentized version of Active
Server Pages called ASP.NET.
219.What is the common language runtime (CLR)?
The common language runtime is the execution engine for .NET
Framework applications.
It provides a number of services, including the following:
• Code management (loading and execution)
• Application memory isolation
• Verification of type safety
• Conversion of IL to native code
• Access to metadata (enhanced type information)
• Managing memory for managed objects
• Enforcement of code access security
• Exception handling, including cross-language exceptions
• Interoperation between managed code, COM objects, and pre-
existing DLLs (unmanaged code and data)
• Automation of object layout
• Support for developer services (profiling, debugging, and so
on)
220.What is the common type system (CTS)?
The common type system is a rich type system, built into the
common language runtime, that supports the types and
operations found in most programming languages. The common
type system supports the complete implementation of a wide
range of programming languages.
221.What is the Common Language Specification (CLS)?
The Common Language Specification is a set of constructs and
constraints that serves as a guide for library writers and compiler
writers. It allows libraries to be fully usable from any language
supporting the CLS, and for those languages to integrate with
each other. The Common Language Specification is a subset of
the common type system. The Common Language Specification
is also important to application developers who are writing code
that will be used by other developers. When developers design
publicly accessible APIs following the rules of the CLS, those
APIs are easily used from all other programming languages that
target the common language runtime.
222.What is the Microsoft Intermediate Language (MSIL)?
MSIL is the CPU-independent instruction set into which .NET
Framework programs are compiled. It contains instructions for
loading, storing, initializing, and calling methods on objects.
Combined with metadata and the common type system, MSIL
allows for true cross-language integration.
Prior to execution, MSIL is converted to machine code. It is not
interpreted.
223.What is managed code and managed data?
Managed code is code that is written to target the services of the
common language runtime (see What is the Common Language
Runtime?). In order to target these services, the code must
provide a minimum level of information (metadata) to the
runtime. All C#, Visual Basic .NET, and JScript .NET code is
managed by default. Visual Studio .NET C++ code is not
managed by default, but the compiler can produce managed
code by specifying a command-line switch (/CLR).
Closely related to managed code is managed data—data that is
allocated and de-allocated by the common language runtime's
garbage collector. C#, Visual Basic, and JScript .NET data is
managed by default. C# data can, however, be marked as
unmanaged through the use of special keywords. Visual Studio
.NET C++ data is unmanaged by default (even when using the
/CLR switch), but when using Managed Extensions for C++, a
class can be marked as managed by using the __gc keyword. As
the name suggests, this means that the memory for instances of
the class is managed by the garbage collector. In addition, the
class becomes a full participating member of the .NET
Framework community, with the benefits and restrictions that
brings. An example of a benefit is proper interoperability with
classes written in other languages (for example, a managed C++
class can inherit from a Visual Basic class). An example of a
restriction is that a managed class can only inherit from one base
class.
224.What is an assembly?
An assembly is the primary building block of a .NET
Framework application. It is a collection of functionality that is
built, versioned, and deployed as a single implementation unit
(as one or more files). All managed types and resources are
marked either as accessible only within their implementation
unit, or as accessible by code outside that unit.
Assemblies are self-describing by means of their manifest,
which is an integral part of every assembly. The manifest:
• Establishes the assembly identity (in the form of a text name),
version, culture, and digital signature (if the assembly is to be
shared across applications).
• Defines what files (by name and file hash) make up the
assembly implementation.
• Specifies the types and resources that make up the assembly,
including which are exported from the assembly.
• Itemizes the compile-time dependencies on other assemblies.
• Specifies the set of permissions required for the assembly to
run properly.
This information is used at run time to resolve references,
enforce version binding policy, and validate the integrity of
loaded assemblies. The runtime can determine and locate the
assembly for any running object, since every type is loaded in
the context of an assembly. Assemblies are also the unit at which
code access security permissions are applied. The identity
evidence for each assembly is considered separately when
determining what permissions to grant the code it contains.
The self-describing nature of assemblies also helps makes zero-
impact install and XCOPY deployment feasible.
225.What are private assemblies and shared assemblies?
A private assembly is used only by a single application, and is
stored in that application's install directory (or a subdirectory
therein). A shared assembly is one that can be referenced by
more than one application. In order to share an assembly, the
assembly must be explicitly built for this purpose by giving it a
cryptographically strong name (referred to as a strong name). By
contrast, a private assembly name need only be unique within
the application that uses it.
By making a distinction between private and shared assemblies,
we introduce the notion of sharing as an explicit decision.
Simply by deploying private assemblies to an application
directory, you can guarantee that that application will run only
with the bits it was built and deployed with. References to
private assemblies will only be resolved locally to the private
application directory.
There are several reasons you may elect to build and use shared
assemblies, such as the ability to express version policy. The fact
that shared assemblies have a cryptographically strong name
means that only the author of the assembly has the key to
produce a new version of that assembly. Thus, if you make a
policy statement that says you want to accept a new version of
an assembly, you can have some confidence that version updates
will be controlled and verified by the author. Otherwise, you
don't have to accept them.
For locally installed applications, a shared assembly is typically
explicitly installed into the global assembly cache (a local cache
of assemblies maintained by the .NET Framework). Key to the
version management features of the .NET Framework is that
downloaded code does not affect the execution of locally
installed applications. Downloaded code is put in a special
download cache and is not globally available on the machine
even if some of the downloaded components are built as shared
assemblies.
The classes that ship with the .NET Framework are all built as
shared assemblies.
226.If I want to build a shared assembly, does that require
the overhead of signing and managing key pairs?
Building a shared assembly does involve working with
cryptographic keys. Only the public key is strictly needed when
the assembly is being built. Compilers targeting the .NET
Framework provide command line options (or use custom
attributes) for supplying the public key when building the
assembly. It is common to keep a copy of a common public key
in a source database and point build scripts to this key. Before
the assembly is shipped, the assembly must be fully signed with
the corresponding private key. This is done using an SDK tool
called SN.exe (Strong Name).
Strong name signing does not involve certificates like
Authenticode does. There are no third party organizations
involved, no fees to pay, and no certificate chains. In addition,
the overhead for verifying a strong name is much less than it is
for Authenticode. However, strong names do not make any
statements about trusting a particular publisher. Strong names
allow you to ensure that the contents of a given assembly haven't
been tampered with, and that the assembly loaded on your
behalf at run time comes from the same publisher as the one you
developed against. But it makes no statement about whether you
can trust the identity of that publisher.
227.What is the difference between a namespace and an
assembly name?
A namespace is a logical naming scheme for types in which a
simple type name, such as MyType, is preceded with a dot-
separated hierarchical name. Such a naming scheme is
completely under the control of the developer. For example,
types MyCompany.FileAccess.A and MyCompany.FileAccess.B
might be logically expected to have functionality related to file
access. The .NET Framework uses a hierarchical naming
scheme for grouping types into logical categories of related
functionality, such as the Microsoft® ASP.NET application
framework, or remoting functionality. Design tools can make
use of namespaces to make it easier for developers to browse
and reference types in their code. The concept of a namespace is
not related to that of an assembly. A single assembly may
contain types whose hierarchical names have different
namespace roots, and a logical namespace root may span
multiple assemblies. In the .NET Framework, a namespace is a
logical design-time naming convenience, whereas an assembly
establishes the name scope for types at run time.
228.What options are available to deploy my .NET
applications?
The .NET Framework simplifies deployment by making zero-
impact install and XCOPY deployment of applications feasible.
Because all requests are resolved first to the private application
directory, simply copying an application's directory files to disk
is all that is needed to run the application. No registration is
required.
This scenario is particularly compelling for Web applications,
Web Services, and self-contained desktop applications.
However, there are scenarios where XCOPY is not sufficient as
a distribution mechanism. An example is when the application
has little private code and relies on the availability of shared
assemblies, or when the application is not locally installed (but
rather downloaded on demand). For these cases, the .NET
Framework provides extensive code download services and
integration with the Windows Installer. The code download
support provided by the .NET Framework offers several
advantages over current platforms, including incremental
download, code access security (no more Authenticode dialogs),
and application isolation (code downloaded on behalf of one
application doesn't affect other applications). The Windows
Installer is another powerful deployment mechanism available to
.NET applications. All of the features of Windows Installer,
including publishing, advertisement, and application repair will
be available to .NET applications in Windows Installer 2.0.
229.I've written an assembly that I want to use in more than
one application. Where do I deploy it?
Assemblies that are to be used by multiple applications (for
example, shared assemblies) are deployed to the global
assembly cache. In the prerelease and Beta builds, use the /i
option to the GACUtil SDK tool to install an assembly into the
cache:
gacutil /i myDll.dll
Windows Installer 2.0, which ships with Windows XP and
Visual Studio .NET will be able to install assemblies into the
global assembly cache.
230.How can I see what assemblies are installed in the global
assembly cache?
The .NET Framework ships with a Windows shell extension for
viewing the assembly cache. Navigating to % windir%\assembly
with the Windows Explorer activates the viewer.
231.What is an application domain?
An application domain (often AppDomain) is a virtual process
that serves to isolate an application. All objects created within
the same application scope (in other words, anywhere along the
sequence of object activations beginning with the application
entry point) are created within the same application domain.
Multiple application domains can exist in a single operating
system process, making them a lightweight means of application
isolation.
An OS process provides isolation by having a distinct memory
address space. While this is effective, it is also expensive, and
does not scale to the numbers required for large web servers.
The Common Language Runtime, on the other hand, enforces
application isolation by managing the memory use of code
running within the application domain. This ensures that it does
not access memory outside the boundaries of the domain. It is
important to note that only type-safe code can be managed in
this way (the runtime cannot guarantee isolation when unsafe
code is loaded in an application domain).
232.What is garbage collection?
Garbage collection is a mechanism that allows the computer to
detect when an object can no longer be accessed. It then
automatically releases the memory used by that object (as well
as calling a clean-up routine, called a "finalizer," which is
written by the user). Some garbage collectors, like the one used
by .NET, compact memory and therefore decrease your
program's working set.
233.How does non-deterministic garbage collection affect my
code?
For most programmers, having a garbage collector (and using
garbage collected objects) means that you never have to worry
about deallocating memory, or reference counting objects, even
if you use sophisticated data structures. It does require some
changes in coding style, however, if you typically deallocate
system resources (file handles, locks, and so forth) in the same
block of code that releases the memory for an object. With a
garbage collected object you should provide a method that
releases the system resources deterministically (that is, under
your program control) and let the garbage collector release the
memory when it compacts the working set.
234.Can I avoid using the garbage collected heap?
All languages that target the runtime allow you to allocate class
objects from the garbage-collected heap. This brings benefits in
terms of fast allocation, and avoids the need for programmers to
work out when they should explicitly 'free' each object.
The CLR also provides what are called ValueTypes—these are
like classes, except that ValueType objects are allocated on the
runtime stack (rather than the heap), and therefore reclaimed
automatically when your code exits the procedure in which they
are defined. This is how "structs" in C# operate.
Managed Extensions to C++ lets you choose where class objects
are allocated. If declared as managed Classes, with the __gc
keyword, then they are allocated from the garbage-collected
heap. If they don't include the __gc keyword, they behave like
regular C++ objects, allocated from the C++ heap, and freed
explicitly with the "free" method.
Remoting
235.How do in-process and cross-process communication
work in the Common Language Runtime?
There are two aspects to in-process communication: between
contexts within a single application domain, or across
application domains. Between contexts in the same application
domain, proxies are used as an interception mechanism. No
marshaling/serialization is involved. When crossing application
domains, we do marshaling/serialization using the runtime
binary protocol.
Cross-process communication uses a pluggable channel and
formatter protocol, each suited to a specific purpose.
• If the developer specifies an endpoint using the tool
soapsuds.exe to generate a metadata proxy, HTTP channel
with SOAP formatter is the default.
• If a developer is doing explicit remoting in the managed
world, it is necessary to be explicit about what channel and
formatter to use. This may be expressed administratively,
through configuration files, or with API calls to load specific
channels. Options are:
HTTP channel w/ SOAP formatter (HTTP works well on the
Internet, or anytime traffic must travel through firewalls)
TCP channel w/ binary formatter (TCP is a higher
performance option for local-area networks (LANs))
When making transitions between managed and unmanaged
code, the COM infrastructure (specifically, DCOM) is used for
remoting. In interim releases of the CLR, this applies also to
serviced components (components that use COM+ services).
Upon final release, it should be possible to configure any
remotable component.
Distributed garbage collection of objects is managed by a
system called "leased based lifetime." Each object has a lease
time, and when that time expires, the object is disconnected
from the remoting infrastructure of the CLR. Objects have a
default renew time-the lease is renewed when a successful call is
made from the client to the object. The client can also explicitly
renew the lease.
Interoperability
236.Can I use COM objects from a .NET Framework
program?
Yes. Any COM component you have deployed today can be
used from managed code, and in common cases the adaptation is
totally automatic.
Specifically, COM components are accessed from the .NET
Framework by use of a runtime callable wrapper (RCW). This
wrapper turns the COM interfaces exposed by the COM
component into .NET Framework-compatible interfaces. For
OLE automation interfaces, the RCW can be generated
automatically from a type library. For non-OLE automation
interfaces, a developer may write a custom RCW and manually
map the types exposed by the COM interface to .NET
Framework-compatible types.
237.Can .NET Framework components be used from a COM
program?
Yes. Managed types you build today can be made accessible
from COM, and in the common case the configuration is totally
automatic. There are certain new features of the managed
development environment that are not accessible from COM.
For example, static methods and parameterized constructors
cannot be used from COM. In general, it is a good idea to decide
in advance who the intended user of a given type will be. If the
type is to be used from COM, you may be restricted to using
those features that are COM accessible.
Depending on the language used to write the managed type, it
may or may not be visible by default.
Specifically, .NET Framework components are accessed from
COM by using a COM callable wrapper (CCW). This is similar
to an RCW (see previous question), but works in the opposite
direction. Again, if the .NET Framework development tools
cannot automatically generate the wrapper, or if the automatic
behavior is not what you want, a custom CCW can be
developed.
238.Can I use the Win32 API from a .NET Framework
program?
Yes. Using platform invoke, .NET Framework programs can
access native code libraries by means of static DLL entry points.
MS SQL Server interview questions
239.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.
240.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.
241.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.
242.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.
243.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.
244.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.
245.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.
246.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.
247.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.
248.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.
249.h TCP/IP port does SQL Server run on? - SQL Server
runs on port 1433 but we can also change it for better security.
250. where can you change the default port? - From the
Network Utility TCP/IP properties –> Port number.both on
client and the server.
251.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.
252.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.
253. 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.
254.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.
255. command do we use to rename a db? - sp_renamedb
‘oldname’ , ‘newname’
256. 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.
257. 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.
258. 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.
259. is a Join in SQL Server? - Join actually puts data from
two or more tables into a single result set.
260.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
261. 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..
262. 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.
263.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.
264.Which stored procedure will you be running to add a
linked server? - sp_addlinkedserver, sp_addlinkedsrvlogin
265.What are the OS services that the SQL Server
installation adds? - MS SQL SERVER SERVICE, SQL
AGENT SERVICE, DTC (Distribution transac co-ordinator)
266.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
267.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
268.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.
269.What are the authentication modes in SQL Server? -
Windows mode and mixed mode (SQL & Windows).
270.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.
271.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.
272.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.
273.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).
274.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.
275.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.
276.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.
277.What is .NET Framework?
The .NET Framework has two main components: the common
language runtime and the .NET Framework class library.
You can think of the runtime as an agent that manages code at
execution time, providing core services such as memory
management, thread management, and remoting, while also
enforcing strict type safety and other forms of code accuracy
that ensure security and robustness.
The class library, is a comprehensive, object-oriented collection
of reusable types that you can use to develop applications
ranging from traditional command-line or graphical user
interface (GUI) applications to applications based on the latest
innovations provided by ASP.NET, such as Web Forms and
XML Web services.
What is CLR, CTS, CLS?
The .NET Framework provides a runtime environment called
the Common Language Runtime or CLR (similar to the Java
Virtual Machine or JVM in Java), which handles the execution
of code and provides useful services for the implementation of
the program. CLR takes care of code management at program
execution and provides various beneficial services such as
memory management, thread management, security
management, code verification, compilation, and other system
services. The managed code that targets CLR benefits from
useful features such as cross-language integration, cross-
language exception handling, versioning, enhanced security,
deployment support, and debugging.
Common Type System (CTS) describes how types are declared,
used and managed in the runtime and facilitates cross-language
integration, type safety, and high performance code execution.
The CLS is simply a specification that defines the rules to
support language integration in such a way that programs
written in any language, yet can interoperate with one another,
taking full advantage of inheritance, polymorphism, exceptions,
and other features. These rules and the specification are
documented in the ECMA proposed standard document,
"Partition I Architecture", http://msdn.microsoft.com/net/ecma/
What are the new features of Framework 1.1 ?
Native Support for Developing Mobile Web Applications
Enable Execution of Windows Forms Assemblies Originating
from the Internet
Assemblies originating from the Internet zone—for example,
Microsoft Windows® Forms controls embedded in an Internet-
based Web page or Windows Forms assemblies hosted on an
Internet Web server and loaded either through the Web browser
or programmatically using the
System.Reflection.Assembly.LoadFrom() method—now receive
sufficient permission to execute in a semi-trusted manner.
Default security policy has been changed so that assemblies
assigned by the common language runtime (CLR) to the Internet
zone code group now receive the constrained permissions
associated with the Internet permission set. In the .NET
Framework 1.0 Service Pack 1 and Service Pack 2, such
applications received the permissions associated with the
Nothing permission set and could not execute.
Enable Code Access Security for ASP.NET Applications
Systems administrators can now use code access security to
further lock down the permissions granted to ASP.NET Web
applications and Web services. Although the operating system
account under which an application runs imposes security
restrictions on the application, the code access security system
of the CLR can enforce additional restrictions on selected
application resources based on policies specified by systems
administrators. You can use this feature in a shared server
environment (such as an Internet service provider (ISP) hosting
multiple Web applications on one server) to isolate separate
applications from one another, as well as with stand-alone
servers where you want applications to run with the minimum
necessary privileges.
Native Support for Communicating with ODBC and Oracle
Databases
Unified Programming Model for Smart Client Application
Development
The Microsoft .NET Compact Framework brings the CLR,
Windows Forms controls, and other .NET Framework features
to small devices. The .NET Compact Framework supports a
large subset of the .NET Framework class library optimized for
small devices.
Support for IPv6
The .NET Framework 1.1 supports the emerging update to the
Internet Protocol, commonly referred to as IP version 6, or
simply IPv6. This protocol is designed to significantly increase
the address space used to identify communication endpoints in
the Internet to accommodate its ongoing growth.
http://msdn.microsoft.com/netframework/technologyinfo/Overvi
ew/whatsnew.aspx
Is .NET a runtime service or a development platform?
Ans: It's both and actually a lot more. Microsoft .NET includes a
new way of delivering software and services to businesses and
consumers. A part of Microsoft.NET is the .NET Frameworks.
The .NET frameworks SDK consists of two parts: the .NET
common language runtime and the .NET class library. In
addition, the SDK also includes command-line compilers for C#,
C++, JScript, and VB. You use these compilers to build
applications and components. These components require the
runtime to execute so this is a development platform.
What is MSIL, IL?
When compiling to managed code, the compiler translates your
source code into Microsoft intermediate language (MSIL),
which is a CPU-independent set of instructions that can be
efficiently converted to native code. MSIL includes instructions
for loading, storing, initializing, and calling methods on objects,
as well as instructions for arithmetic and logical operations,
control flow, direct memory access, exception handling, and
other operations. Microsoft intermediate language (MSIL) is a
language used as the output of a number of compilers and as the
input to a just-in-time (JIT) compiler. The common language
runtime includes a JIT compiler for converting MSIL to native
code.
Can I write IL programs directly?
Yes. Peter Drayton posted this simple example to the DOTNET
mailing list:
.assembly MyAssembly {}
.class MyApp {
.method static void Main() {
.entrypoint
ldstr "Hello, IL!"
call void System.Console::WriteLine(class
System.Object)
ret
}
}
Just put this into a file called hello.il, and then run ilasm hello.il.
An exe assembly will be generated.
Can I do things in IL that I can't do in C#?
Yes. A couple of simple examples are that you can throw
exceptions that are not derived from System.Exception, and you
can have non-zero-based arrays.
What is JIT (just in time)? how it works?
Before Microsoft intermediate language (MSIL) can be
executed, it must be converted by a .NET Framework just-in-
time (JIT) compiler to native code, which is CPU-specific code
that runs on the same computer architecture as the JIT compiler.
Rather than using time and memory to convert all the MSIL in a
portable executable (PE) file to native code, it converts the
MSIL as it is needed during execution and stores the resulting
native code so that it is accessible for subsequent calls.
The runtime supplies another mode of compilation called install-
time code generation. The install-time code generation mode
converts MSIL to native code just as the regular JIT compiler
does, but it converts larger units of code at a time, storing the
resulting native code for use when the assembly is subsequently
loaded and executed.
As part of compiling MSIL to native code, code must pass a
verification process unless an administrator has established a
security policy that allows code to bypass verification.
Verification examines MSIL and metadata to find out whether
the code can be determined to be type safe, which means that it
is known to access only the memory locations it is authorized to
access.
What is strong name?
A name that consists of an assembly's identity—its simple text
name, version number, and culture information (if provided)—
strengthened by a public key and a digital signature generated
over the assembly.
What is portable executable (PE)?
The file format defining the structure that all executable files
(EXE) and Dynamic Link Libraries (DLL) must use to allow
them to be loaded and executed by Windows. PE is derived from
the Microsoft Common Object File Format (COFF). The EXE
and DLL files created using the .NET Framework obey the
PE/COFF formats and also add additional header and data
sections to the files that are only used by the CLR. The
specification for the PE/COFF file formats is available at
http://www.microsoft.com/whdc/hwdev/hardware/pecoffdown.ms
px
What is Event - Delegate? clear syntax for writing a event
delegate
The event keyword lets you specify a delegate that will be called
upon the occurrence of some "event" in your code. The delegate
can have one or more associated methods that will be called
when your code indicates that the event has occurred. An event
in one program can be made available to other programs that
target the .NET Framework Common Language Runtime.
// keyword_delegate.cs
// delegate declaration
delegate void MyDelegate(int i);
class Program
{
public static void Main()
{
TakesADelegate(new MyDelegate(DelegateFunction));
}
public static void TakesADelegate(MyDelegate
SomeFunction)
{
SomeFunction(21);
}
public static void DelegateFunction(int i)
{
System.Console.WriteLine("Called by delegate with
number: {0}.", i);
}
}
What is Code Access Security (CAS)?
CAS is the part of the .NET security model that determines
whether or not a piece of code is allowed to run, and what
resources it can use when it is running. For example, it is CAS
that will prevent a .NET web applet from formatting your hard
disk.
How does CAS work?
The CAS security policy revolves around two key concepts -
code groups and permissions. Each .NET assembly is a member
of a particular code group, and each code group is granted the
permissions specified in a named permission set.
For example, using the default security policy, a control
downloaded from a web site belongs to the 'Zone - Internet' code
group, which adheres to the permissions defined by the 'Internet'
named permission set. (Naturally the 'Internet' named
permission set represents a very restrictive range of
permissions.)
Who defines the CAS code groups?
Microsoft defines some default ones, but you can modify these
and even create your own. To see the code groups defined on
your system, run 'caspol -lg' from the command-line. On my
syystem it looks like this:
Level = Machine
Code Groups:

1. All code: Nothing


1.1. Zone - MyComputer: FullTrust
1.1.1. Honor SkipVerification requests: SkipVerification
1.2. Zone - Intranet: LocalIntranet
1.3. Zone - Internet: Internet
1.4. Zone - Untrusted: Nothing
1.5. Zone - Trusted: Internet
1.6. StrongName -
002400000480000094000000060200000024000052534131000
4000003
000000CFCB3291AA715FE99D40D49040336F9056D7886FE
D46775BC7BB5430BA4444FEF8348EBD06
F962F39776AE4DC3B7B04A7FE6F49F25F740423EBF2C0B8
9698D8D08AC48D69CED0FC8F83B465E08
07AC11EC1DCC7D054E807A43336DDE408A5393A4855612
3272CEEEE72F1660B71927D38561AABF5C
AC1DF1734633C602F8F2D5: Everything
Note the hierarchy of code groups - the top of the hierarchy is
the most general ('All code'), which is then sub-divided into
several groups, each of which in turn can be sub-divided. Also
note that (somewhat counter-intuitively) a sub-group can be
associated with a more permissive permission set than its parent.

How do I define my own code group?


Use caspol. For example, suppose you trust code from
www.mydomain.com and you want it have full access to your
system, but you want to keep the default restrictions for all other
internet sites. To achieve this, you would add a new code group
as a sub-group of the 'Zone - Internet' group, like this:
caspol -ag 1.3 -site www.mydomain.com FullTrust
Now if you run caspol -lg you will see that the new group has
been added as group 1.3.1:
...
1.3. Zone - Internet: Internet
1.3.1. Site - www.mydomain.com: FullTrust
...
Note that the numeric label (1.3.1) is just a caspol invention to
make the code groups easy to manipulate from the command-
line. The underlying runtime never sees it.
How do I change the permission set for a code group?
Use caspol. If you are the machine administrator, you can
operate at the 'machine' level - which means not only that the
changes you make become the default for the machine, but also
that users cannot change the permissions to be more permissive.
If you are a normal (non-admin) user you can still modify the
permissions, but only to make them more restrictive. For
example, to allow intranet code to do what it likes you might do
this:
caspol -cg 1.2 FullTrust
Note that because this is more permissive than the default policy
(on a standard system), you should only do this at the machine
level - doing it at the user level will have no effect.
Can I create my own permission set?
Yes. Use caspol -ap, specifying an XML file containing the
permissions in the permission set. To save you some time, here
is a sample file corresponding to the 'Everything' permission set
- just edit to suit your needs. When you have edited the sample,
add it to the range of available permission sets like this:
caspol -ap samplepermset.xml
Then, to apply the permission set to a code group, do something
like this:
caspol -cg 1.3 SamplePermSet (By default, 1.3 is the 'Internet'
code group)
I'm having some trouble with CAS. How can I diagnose my
problem?
Caspol has a couple of options that might help. First, you can
ask caspol to tell you what code group an assembly belongs to,
using caspol -rsg. Similarly, you can ask what permissions are
being applied to a particular assembly using caspol -rsp.
I can't be bothered with all this CAS stuff. Can I turn it off?
Yes, as long as you are an administrator. Just run:
caspol -s off
http://www.codeproject.com/dotnet/UB_CAS_NET.asp
Which namespace is the base class for .net Class library?
Ans: system.object
What are object pooling and connection pooling and difference?
Where do we set the Min and Max Pool size for connection
pooling?
Object pooling is a COM+ service that enables you to reduce the
overhead of creating each object from scratch. When an object is
activated, it is pulled from the pool. When the object is
deactivated, it is placed back into the pool to await the next
request. You can configure object pooling by applying the
ObjectPoolingAttribute attribute to a class that derives from the
System.EnterpriseServices.ServicedComponent class.
Object pooling lets you control the number of connections you
use, as opposed to connection pooling, where you control the
maximum number reached.
Following are important differences between object pooling and
connection pooling:
Creation. When using connection pooling, creation is on the
same thread, so if there is nothing in the pool, a connection is
created on your behalf. With object pooling, the pool might
decide to create a new object. However, if you have already
reached your maximum, it instead gives you the next available
object. This is crucial behavior when it takes a long time to
create an object, but you do not use it for very long.
Enforcement of minimums and maximums. This is not done in
connection pooling. The maximum value in object pooling is
very important when trying to scale your application. You might
need to multiplex thousands of requests to just a few objects.
(TPC/C benchmarks rely on this.)
COM+ object pooling is identical to what is used in .NET
Framework managed SQL Client connection pooling. For
example, creation is on a different thread and minimums and
maximums are enforced.
What is Application Domain?
The primary purpose of the AppDomain is to isolate an
application from other applications. Win32 processes provide
isolation by having distinct memory address spaces. This is
effective, but it is expensive and doesn't scale well. The .NET
runtime enforces AppDomain isolation by keeping control over
the use of memory - all memory in the AppDomain is managed
by the .NET runtime, so the runtime can ensure that
AppDomains do not access each other's memory.
Objects in different application domains communicate either by
transporting copies of objects across application domain
boundaries, or by using a proxy to exchange messages.
MarshalByRefObject is the base class for objects that
communicate across application domain boundaries by
exchanging messages using a proxy. Objects that do not inherit
from MarshalByRefObject are implicitly marshal by value.
When a remote application references a marshal by value object,
a copy of the object is passed across application domain
boundaries.
How does an AppDomain get created?
AppDomains are usually created by hosts. Examples of hosts are
the Windows Shell, ASP.NET and IE. When you run a .NET
application from the command-line, the host is the Shell. The
Shell creates a new AppDomain for every application.
AppDomains can also be explicitly created by .NET
applications. Here is a C# sample which creates an AppDomain,
creates an instance of an object inside it, and then executes one
of the object's methods. Note that you must name the executable
'appdomaintest.exe' for this code to work as-is.
using System;
using System.Runtime.Remoting;

public class CAppDomainInfo : MarshalByRefObject


{
public string GetAppDomainInfo()
{
return "AppDomain = " +
AppDomain.CurrentDomain.FriendlyName;
}
}
public class App
{
public static int Main()
{
AppDomain ad = AppDomain.CreateDomain( "Andy's
new domain", null, null );
ObjectHandle oh = ad.CreateInstance(
"appdomaintest", "CAppDomainInfo" );
CAppDomainInfo adInfo =
(CAppDomainInfo)(oh.Unwrap());
string info = adInfo.GetAppDomainInfo();
Console.WriteLine( "AppDomain info: " + info );
return 0;
}
}
What is serialization in .NET? What are the ways to control
serialization?
Serialization is the process of converting an object into a stream
of bytes. Deserialization is the opposite process of creating an
object from a stream of bytes. Serialization/Deserialization is
mostly used to transport objects (e.g. during remoting), or to
persist objects (e.g. to a file or database).Serialization can be
defined as the process of storing the state of an object to a
storage medium. During this process, the public and private
fields of the object and the name of the class, including the
assembly containing the class, are converted to a stream of
bytes, which is then written to a data stream. When the object is
subsequently deserialized, an exact clone of the original object is
created.
Binary serialization preserves type fidelity, which is useful for
preserving the state of an object between different invocations of
an application. For example, you can share an object between
different applications by serializing it to the clipboard. You can
serialize an object to a stream, disk, memory, over the network,
and so forth. Remoting uses serialization to pass objects "by
value" from one computer or application domain to another.
XML serialization serializes only public properties and fields
and does not preserve type fidelity. This is useful when you want
to provide or consume data without restricting the application
that uses the data. Because XML is an open standard, it is an
attractive choice for sharing data across the Web. SOAP is an
open standard, which makes it an attractive choice.
There are two separate mechanisms provided by the .NET class
library - XmlSerializer and SoapFormatter/BinaryFormatter.
Microsoft uses XmlSerializer for Web Services, and uses
SoapFormatter/BinaryFormatter for remoting. Both are available
for use in your own code.
Why do I get errors when I try to serialize a Hashtable?
XmlSerializer will refuse to serialize instances of any class that
implements IDictionary, e.g. Hashtable. SoapFormatter and
BinaryFormatter do not have this restriction.
What is exception handling?
When an exception occurs, the system searches for the nearest
catch clause that can handle the exception, as determined by the
run-time type of the exception. First, the current method is
searched for a lexically enclosing try statement, and the
associated catch clauses of the try statement are considered in
order. If that fails, the method that called the current method is
searched for a lexically enclosing try statement that encloses the
point of the call to the current method. This search continues
until a catch clause is found that can handle the current
exception, by naming an exception class that is of the same
class, or a base class, of the run-time type of the exception being
thrown. A catch clause that doesn't name an exception class can
handle any exception.
Once a matching catch clause is found, the system prepares to
transfer control to the first statement of the catch clause. Before
execution of the catch clause begins, the system first executes, in
order, any finally clauses that were associated with try
statements more nested that than the one that caught the
exception.
Exceptions that occur during destructor execution are worth
special mention. If an exception occurs during destructor
execution, and that exception is not caught, then the execution of
that destructor is terminated and the destructor of the base class
(if any) is called. If there is no base class (as in the case of the
object type) or if there is no base class destructor, then the
exception is discarded.
What is Assembly?
Assemblies are the building blocks of .NET Framework
applications; they form the fundamental unit of deployment,
version control, reuse, activation scoping, and security
permissions. An assembly is a collection of types and resources
that are built to work together and form a logical unit of
functionality. An assembly provides the common language
runtime with the information it needs to be aware of type
implementations. To the runtime, a type does not exist outside
the context of an assembly.
Assemblies are a fundamental part of programming with the
.NET Framework. An assembly performs the following
functions:
It contains code that the common language runtime executes.
Microsoft intermediate language (MSIL) code in a portable
executable (PE) file will not be executed if it does not have an
associated assembly manifest. Note that each assembly can have
only one entry point (that is, DllMain, WinMain, or Main).
It forms a security boundary. An assembly is the unit at which
permissions are requested and granted.
It forms a type boundary. Every type's identity includes the
name of the assembly in which it resides. A type called MyType
loaded in the scope of one assembly is not the same as a type
called MyType loaded in the scope of another assembly.
It forms a reference scope boundary. The assembly's manifest
contains assembly metadata that is used for resolving types and
satisfying resource requests. It specifies the types and resources
that are exposed outside the assembly. The manifest also
enumerates other assemblies on which it depends.
It forms a version boundary. The assembly is the smallest
versionable unit in the common language runtime; all types and
resources in the same assembly are versioned as a unit. The
assembly's manifest describes the version dependencies you
specify for any dependent assemblies.
It forms a deployment unit. When an application starts, only the
assemblies that the application initially calls must be present.
Other assemblies, such as localization resources or assemblies
containing utility classes, can be retrieved on demand. This
allows applications to be kept simple and thin when first
downloaded.
It is the unit at which side-by-side execution is supported.
Assemblies can be static or dynamic. Static assemblies can
include .NET Framework types (interfaces and classes), as well
as resources for the assembly (bitmaps, JPEG files, resource
files, and so on). Static assemblies are stored on disk in PE files.
You can also use the .NET Framework to create dynamic
assemblies, which are run directly from memory and are not
saved to disk before execution. You can save dynamic
assemblies to disk after they have executed.
There are several ways to create assemblies. You can use
development tools, such as Visual Studio .NET, that you have
used in the past to create .dll or .exe files. You can use tools
provided in the .NET Framework SDK to create assemblies with
modules created in other development environments. You can
also use common language runtime APIs, such as
Reflection.Emit, to create dynamic assemblies.
What are the contents of assembly?
In general, a static assembly can consist of four elements:
The assembly manifest, which contains assembly metadata.
Type metadata.
Microsoft intermediate language (MSIL) code that implements
the types.
A set of resources.
What are the different types of assemblies?
Private, Public/Shared, Satellite
What is the difference between a private assembly and a shared
assembly?
Location and visibility: A private assembly is normally used by a
single application, and is stored in the application's directory, or
a sub-directory beneath. A shared assembly is normally stored in
the global assembly cache, which is a repository of assemblies
maintained by the .NET runtime. Shared assemblies are usually
libraries of code which many applications will find useful, e.g.
the .NET framework classes.
Versioning: The runtime enforces versioning constraints only on
shared assemblies, not on private assemblies.
What are Satellite Assemblies? How you will create this? How
will you get the different language strings?
Satellite assemblies are often used to deploy language-specific
resources for an application. These language-specific assemblies
work in side-by-side execution because the application has a
separate product ID for each language and installs satellite
assemblies in a language-specific subdirectory for each
language. When uninstalling, the application removes only the
satellite assemblies associated with a given language and .NET
Framework version. No core .NET Framework files are removed
unless the last language for that .NET Framework version is
being removed.
(For example, English and Japanese editions of the .NET
Framework version 1.1 share the same core files. The Japanese
.NET Framework version 1.1 adds satellite assemblies with
localized resources in a \ja subdirectory. An application that
supports the .NET Framework version 1.1, regardless of its
language, always uses the same core runtime files.)
http://www.ondotnet.com/lpt/a/2637
**
How will u load dynamic assembly? How will create assemblies
at run time?
**
What is Assembly manifest? what all details the assembly
manifest will contain?
Every assembly, whether static or dynamic, contains a collection
of data that describes how the elements in the assembly relate to
each other. The assembly manifest contains this assembly
metadata. An assembly manifest contains all the metadata
needed to specify the assembly's version requirements and
security identity, and all metadata needed to define the scope of
the assembly and resolve references to resources and classes.
The assembly manifest can be stored in either a PE file (an .exe
or .dll) with Microsoft intermediate language (MSIL) code or in
a standalone PE file that contains only assembly manifest
information.
It contains Assembly name, Version number, Culture, Strong
name information, List of all files in the assembly, Type
reference information, Information on referenced assemblies.
Difference between assembly manifest & metadata?
assembly manifest - An integral part of every assembly that
renders the assembly self-describing. The assembly manifest
contains the assembly's metadata. The manifest establishes the
assembly identity, specifies the files that make up the assembly
implementation, specifies the types and resources that make up
the assembly, itemizes the compile-time dependencies on other
assemblies, and specifies the set of permissions required for the
assembly to run properly. This information is used at run time to
resolve references, enforce version binding policy, and validate
the integrity of loaded assemblies. The self-describing nature of
assemblies also helps makes zero-impact install and XCOPY
deployment feasible.
metadata - Information that describes every element managed by
the common language runtime: an assembly, loadable file, type,
method, and so on. This can include information required for
debugging and garbage collection, as well as security attributes,
marshaling data, extended class and member definitions, version
binding, and other information required by the runtime.
What is Global Assembly Cache (GAC) and what is the purpose
of it? (How to make an assembly to public? Steps) How more
than one version of an assembly can keep in same place?
Each computer where the common language runtime is installed
has a machine-wide code cache called the global assembly
cache. The global assembly cache stores assemblies specifically
designated to be shared by several applications on the computer.
You should share assemblies by installing them into the global
assembly cache only when you need to.
Steps
- Create a strong name using sn.exe tool
eg: sn -k keyPair.snk
- with in AssemblyInfo.cs add the generated file name
eg: [assembly: AssemblyKeyFile("abc.snk")]
- recompile project, then install it to GAC by either
drag & drop it to assembly folder (C:\WINDOWS\assembly OR
C:\WINNT\assembly) (shfusion.dll tool)
or
gacutil -i abc.dll
If I have more than one version of one assemblies, then how'll I
use old version (how/where to specify version number?)in my
application?
**
How to find methods of a assembly file (not using ILDASM)
Reflection
What is Garbage Collection in .Net? Garbage collection
process?
The process of transitively tracing through all pointers to
actively used objects in order to locate all objects that can be
referenced, and then arranging to reuse any heap memory that
was not found during this trace. The common language runtime
garbage collector also compacts the memory that is in use to
reduce the working space needed for the heap.
What is Reflection in .NET? Namespace? How will you load an
assembly which is not referenced by current assembly?
All .NET compilers produce metadata about the types defined in
the modules they produce. This metadata is packaged along with
the module (modules in turn are packaged together in
assemblies), and can be accessed by a mechanism called
reflection. The System.Reflection namespace contains classes
that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to
using ITypeLib/ITypeInfo to access type library data in COM,
and it is used for similar purposes - e.g. determining data type
sizes for marshaling data across context/process/machine
boundaries.
Reflection can also be used to dynamically invoke methods (see
System.Type.InvokeMember), or even create types dynamically
at run-time (see System.Reflection.Emit.TypeBuilder).
What is Custom attribute? How to create? If I'm having custom
attribute in an assembly, how to say that name in the code?
A: The primary steps to properly design custom attribute classes
are as follows:
Applying the AttributeUsageAttribute
([AttributeUsage(AttributeTargets.All, Inherited = false,
AllowMultiple = true)])
Declaring the attribute. (class public class MyAttribute :
System.Attribute { // . . . })
Declaring constructors (public MyAttribute(bool myvalue)
{ this.myvalue = myvalue; })
Declaring properties
public bool MyProperty
{
get {return this.myvalue;}
set {this.myvalue = value;}
}
The following example demonstrates the basic way of using
reflection to get access to custom attributes.
class MainClass
{
public static void Main()
{
System.Reflection.MemberInfo info = typeof(MyClass);
object[] attributes = info.GetCustomAttributes();
for (int i = 0; i < attributes.Length; i ++)
{
System.Console.WriteLine(attributes[i]);
}
}
}
What is the managed and unmanaged code in .net?
The .NET Framework provides a run-time environment called
the Common Language Runtime, which manages the execution
of code and provides services that make the development
process easier. Compilers and tools expose the runtime's
functionality and enable you to write code that benefits from this
managed execution environment. Code that you develop with a
language compiler that targets the runtime is called managed
code; it benefits from features such as cross-language
integration, cross-language exception handling, enhanced
security, versioning and deployment support, a simplified model
for component interaction, and debugging and profiling services.
How do you create threading in .NET? What is the namespace
for that?
**
System.Threading.Thread
Serialize and MarshalByRef?
using directive vs using statement
You create an instance in a using statement to ensure that
Dispose is called on the object when the using statement is
exited. A using statement can be exited either when the end of
the using statement is reached or if, for example, an exception is
thrown and control leaves the statement block before the end of
the statement.
The using directive has two uses:
Create an alias for a namespace (a using alias).
Permit the use of types in a namespace, such that, you do not
have to qualify the use of a type in that namespace (a using
directive).
Describe the Managed Execution Process?
The managed execution process includes the following steps:
Choosing a compiler.
To obtain the benefits provided by the common language
runtime, you must use one or more language compilers that
target the runtime.
Compiling your code to Microsoft intermediate language
(MSIL).
Compiling translates your source code into MSIL and generates
the required metadata.
Compiling MSIL to native code.
At execution time, a just-in-time (JIT) compiler translates the
MSIL into native code. During this compilation, code must pass
a verification process that examines the MSIL and metadata to
find out whether the code can be determined to be type safe.
Executing your code.
The common language runtime provides the infrastructure that
enables execution to take place as well as a variety of services
that can be used during execution.
What is Active Directory? What is the namespace used to access
the Microsoft Active Directories? What are ADSI Directories?
Active Directory Service Interfaces (ADSI) is a programmatic
interface for Microsoft Windows Active Directory. It enables
your applications to interact with diverse directories on a
network, using a single interface. Visual Studio .NET and the
.NET Framework make it easy to add ADSI functionality with
the DirectoryEntry and DirectorySearcher components.
Using ADSI, you can create applications that perform common
administrative tasks, such as backing up databases, accessing
printers, and administering user accounts. ADSI makes it
possible for you to:
Log on once to work with diverse directories. The
DirectoryEntry component class provides username and
password properties that can be entered at runtime and
communicated to the Active Directory object you are binding to.
Use a single application programming interface (API) to
perform tasks on multiple directory systems by offering the user
a variety of protocols to use. The DirectoryServices namespace
provides the classes to perform most administrative functions.
Perform "rich querying" on directory systems. ADSI technology
allows for searching for an object by specifying two query
dialects: SQL and LDAP.
Access and use a single, hierarchical structure for administering
and maintaining diverse and complicated network configurations
by accessing an Active Directory tree.
Integrate directory information with databases such as SQL
Server. The DirectoryEntry path may be used as an ADO.NET
connection string provided that it is using the LDAP provider.
using System.DirectoryServices;
How Garbage Collector (GC) Works?
The methods in this class influence when an object is garbage
collected and when resources allocated by an object are released.
Properties in this class provide information about the total
amount of memory available in the system and the age category,
or generation, of memory allocated to an object. Periodically, the
garbage collector performs garbage collection to reclaim
memory allocated to objects for which there are no valid
references. Garbage collection happens automatically when a
request for memory cannot be satisfied using available free
memory. Alternatively, an application can force garbage
collection using the Collect method.
Garbage collection consists of the following steps:
The garbage collector searches for managed objects that are
referenced in managed code.
The garbage collector attempts to finalize objects that are not
referenced.
The garbage collector frees objects that are not referenced and
reclaims their memory.
Why do we need to call CG.SupressFinalize?
Requests that the system not call the finalizer method for the
specified object.
public static void SuppressFinalize(
object obj
); The method removes obj from the set of objects that require
finalization. The obj parameter is required to be the caller of this
method.
Objects that implement the IDisposable interface can call this
method from the IDisposable.Dispose method to prevent the
garbage collector from calling Object.Finalize on an object that
does not require it.
What is nmake tool?
The Nmake tool (Nmake.exe) is a 32-bit tool that you use to
build projects based on commands contained in a .mak file.
usage : nmake -a all
What are Namespaces?
The namespace keyword is used to declare a scope. This
namespace scope lets you organize code and gives you a way to
create globally-unique types. Even if you do not explicitly
declare one, a default namespace is created. This unnamed
namespace, sometimes called the global namespace, is present in
every file. Any identifier in the global namespace is available for
use in a named namespace. Namespaces implicitly have public
access and this is not modifiable.
What is the difference between CONST and READONLY?
Both are meant for constant values. A const field can only be
initialized at the declaration of the field. A readonly field can be
initialized either at the declaration or in a constructor. Therefore,
readonly fields can have different values depending on the
constructor used.
readonly int b;
public X()
{
b=1;
}
public X(string s)
{
b=5;
}
public X(string s, int i)
{
b=i;
}
Also, while a const field is a compile-time constant, the readonly
field can be used for runtime constants, as in the following
example:
public static readonly uint l1 = (uint) DateTime.Now.Ticks; (this
can't be possible with const)
What is the difference between ref & out parameters?
An argument passed to a ref parameter must first be initialized.
Compare this to an out parameter, whose argument does not
have to be explicitly initialized before being passed to an out
parameter.
What is the difference between Array and LinkedList?
What is the difference between Array and Arraylist?
As elements are added to an ArrayList, the capacity is
automatically increased as required through reallocation. The
capacity can be decreased by calling TrimToSize or by setting
the Capacity property explicitly.
What is Jagged Arrays?
A jagged array is an array whose elements are arrays. The
elements of a jagged array can be of different dimensions and
sizes. A jagged array is sometimes called an "array-of-arrays."
What are indexers?
Indexers are similar to properties, except that the get and set
accessors of indexers take parameters, while property accessors
do not.
What is Asynchronous call and how it can be implemented using
delegates?
How to create events for a control? What is custom events? How
to create it?
If you want to write your own dot net language, what steps you
will u take care?
Describe the difference between inline and code behind - which
is best in a loosely coupled solution?
how dot net compiled code will become platform independent?
without modifying source code if we compile again, will it be
generated MSIL again?
C++ & C# differences
**

(COM)
Interop Services?
The common language runtime provides two mechanisms for
interoperating with unmanaged code:
Platform invoke, which enables managed code to call functions
exported from an unmanaged library.
COM interop, which enables managed code to interact with
COM objects through interfaces.
Both platform invoke and COM interop use interop marshaling
to accurately move method arguments between caller and callee
and back, if required.
How does u handle this COM components developed in other
programming languages in .NET?
What is RCW (Runtime Callable Wrappers)?
The common language runtime exposes COM objects through a
proxy called the runtime callable wrapper (RCW). Although the
RCW appears to be an ordinary object to .NET clients, its
primary function is to marshal calls between a .NET client and a
COM object.
What is CCW (COM Callable Wrapper)
A proxy object generated by the common language runtime so
that existing COM applications can use managed classes,
including .NET Framework classes, transparently.
How CCW and RCW is working?
**
How will you register com+ services?
The .NET Framework SDK provides the .NET Framework
Services Installation Tool (Regsvcs.exe - a command-line tool)
to manually register an assembly containing serviced
components. You can also access these registration features
programmatically with the
System.EnterpriseServicesRegistrationHelper class by creating
an instance of class RegistrationHelper and using the method
InstallAssembly
What is use of ContextUtil class?
ContextUtil is the preferred class to use for obtaining COM+
context information.
What is the new three features of COM+ services, which are not
there in COM (MTS)?
**
Is the COM architecture same as .Net architecture? What is the
difference between them?
**
Can we copy a COM dll to GAC folder?
**
What is Pinvoke?
Platform invoke is a service that enables managed code to call
unmanaged functions implemented in dynamic-link libraries
(DLLs), such as those in the Win32 API. It locates and invokes
an exported function and marshals its arguments (integers,
strings, arrays, structures, and so on) across the interoperation
boundary as needed.
Is it true that COM objects no longer need to be registered on
the server?
Answer: Yes and No. Legacy COM objects still need to be
registered on the server before they can be used. COM
developed using the new .NET Framework will not need to be
registered. Developers will be able to auto-register these objects
just by placing them in the 'bin' folder of the application.
Can .NET Framework components use the features of
Component Services?
Answer: Yes, you can use the features and functions of
Component Services from a .NET Framework component.
http://msdn.microsoft.com/library/techart/Pahlcompserv.htm

(OOPS)
What are the OOPS concepts?
1) Encapsulation: It is the mechanism that binds together code
and data in manipulates, and keeps both safe from outside
interference and misuse. In short it isolates a particular code and
data from all other codes and data. A well-defined interface
controls the access to that particular code and data.
2) Inheritance: It is the process by which one object acquires the
properties of another object. This supports the hierarchical
classification. Without the use of hierarchies, each object would
need to define all its characteristics explicitly. However, by use
of inheritance, an object need only define those qualities that
make it unique within its class. It can inherit its general
attributes from its parent. A new sub-class inherits all of the
attributes of all of its ancestors.
3) Polymorphism: It is a feature that allows one interface to be
used for general class of actions. The specific action is
determined by the exact nature of the situation. In general
polymorphism means "one interface, multiple methods", This
means that it is possible to design a generic interface to a group
of related activities. This helps reduce complexity by allowing
the same interface to be used to specify a general class of action.
It is the compiler's job to select the specific action (that is,
method) as it applies to each situation.
What is the difference between a Struct and a Class?
The struct type is suitable for representing lightweight objects
such as Point, Rectangle, and Color. Although it is possible to
represent a point as a class, a struct is more efficient in some
scenarios. For example, if you declare an array of 1000 Point
objects, you will allocate additional memory for referencing
each object. In this case, the struct is less expensive.
When you create a struct object using the new operator, it gets
created and the appropriate constructor is called. Unlike classes,
structs can be instantiated without using the new operator. If you
do not use new, the fields will remain unassigned and the object
cannot be used until all of the fields are initialized.
It is an error to declare a default (parameterless) constructor for
a struct. A default constructor is always provided to initialize the
struct members to their default values.
It is an error to initialize an instance field in a struct.
There is no inheritance for structs as there is for classes. A struct
cannot inherit from another struct or class, and it cannot be the
base of a class. Structs, however, inherit from the base class
Object. A struct can implement interfaces, and it does that
exactly as classes do.
A struct is a value type, while a class is a reference type.
Value type & reference types difference? Example from .NET.
Integer & struct are value types or reference types in .NET?
Most programming languages provide built-in data types, such
as integers and floating-point numbers, that are copied when
they are passed as arguments (that is, they are passed by value).
In the .NET Framework, these are called value types. The
runtime supports two kinds of value types:
Built-in value types
The .NET Framework defines built-in value types, such as
System.Int32 and System.Boolean, which correspond and are
identical to primitive data types used by programming
languages.
User-defined value types
Your language will provide ways to define your own value
types, which derive from System.ValueType. If you want to
define a type representing a value that is small, such as a
complex number (using two floating-point numbers), you might
choose to define it as a value type because you can pass the
value type efficiently by value. If the type you are defining
would be more efficiently passed by reference, you should
define it as a class instead.
Variables of reference types, referred to as objects, store
references to the actual data. This following are the reference
types:
class
interface
delegate
This following are the built-in reference types:
object
string
What is Inheritance, Multiple Inheritance, Shared and
Repeatable Inheritance?
**
What is Method overloading?
Method overloading occurs when a class contains two methods
with the same name, but different signatures.
What is Method Overriding? How to override a function in C#?
Use the override modifier to modify a method, a property, an
indexer, or an event. An override method provides a new
implementation of a member inherited from a base class. The
method overridden by an override declaration is known as the
overridden base method. The overridden base method must have
the same signature as the override method.
You cannot override a non-virtual or static method. The
overridden base method must be virtual, abstract, or override.
Can we call a base class method without creating instance?
Its possible If its a static method.
Its possible by inheriting from that class also.
Its possible from derived classes using base keyword.
You have one base class virtual function how will call that
function from derived class?
Ans:
class a
{
public virtual int m()
{
return 1;
}
}
class b:a
{
public int j()
{
return m();
}
}
In which cases you use override and new base?
Use the new modifier to explicitly hide a member inherited from
a base class. To hide an inherited member, declare it in the
derived class using the same name, and modify it with the new
modifier.
C# Language features
What are Sealed Classes in C#?
The sealed modifier is used to prevent derivation from a class. A
compile-time error occurs if a sealed class is specified as the
base class of another class. (A sealed class cannot also be an
abstract class)
What is Polymorphism? How does VB.NET/C# achieve
polymorphism?
**
class Token
{
public string Display()
{
//Implementation goes here
return "base";
}
}
class IdentifierToken:Token
{
public new string Display() //What is the use of new
keyword
{
//Implementation goes here
return "derive";
}
}
static void Method(Token t)
{
Console.Write(t.Display());
}
public static void Main()
{
IdentifierToken Variable=new IdentifierToken();
Method(Variable); //Which Class Method is called
here
Console.ReadLine();
}
For the above code What is the "new" keyword and
Which Class Method is
called here
A: it will call base class Display method
class Token
{
public virtual string Display()
{
//Implementation goes here
return "base";
}
}
class IdentifierToken:Token
{
public override string Display() //What is the use of
new keyword
{
//Implementation goes here
return "derive";
}
}
static void Method(Token t)
{
Console.Write(t.Display());
}
public static void Main()
{
IdentifierToken Variable=new IdentifierToken();
Method(Variable); //Which Class Method is called
here
Console.ReadLine();
}
A: Derive
In which Scenario you will go for Interface or Abstract Class?
Interfaces, like classes, define a set of properties, methods, and
events. But unlike classes, interfaces do not provide
implementation. They are implemented by classes, and defined
as separate entities from classes. Even though class inheritance
allows your classes to inherit implementation from a base class,
it also forces you to make most of your design decisions when
the class is first published.
Abstract classes are useful when creating components because
they allow you specify an invariant level of functionality in
some methods, but leave the implementation of other methods
until a specific implementation of that class is needed. They also
version well, because if additional functionality is needed in
derived classes, it can be added to the base class without
breaking code.
Interfaces vs. Abstract Classes
Feature Interface Abstract class
A class may
Multiple implement A class may extend only
inheritance several one abstract class.
interfaces.
An interface An abstract class can
cannot provide provide complete code,
Default
any code at all, default code, and/or just
implementation
much less stubs that have to be
default code. overridden.
Constants Static final Both instance and static
constants only, constants are possible.
can use them Both static and instance
without intialiser code are also
qualification in possible to compute the
classes that constants.
implement the
interface. On the
other paw, these
unqualified
names pollute
the namespace.
You can use
them and it is not
obvious where
they are coming
from since the
qualification is
optional.
An interface
A third party class must
implementation
Third party be rewritten to extend
may be added to
convenience only from the abstract
any existing
class.
third party class.
is-a vs -able or Interfaces are An abstract class defines
can-do often used to the core identity of its
describe the descendants. If you
peripheral defined a Dog abstract
abilities of a class then Damamation
class, not its descendants are Dogs,
central identity, they are not merely
e.g. an dogable. Implemented
Automobile classinterfaces enumerate the
might implement general things a class can
the Recyclable do, not the things a class
interface, which is.
could apply to
many otherwise
totally unrelated
objects.
Plug-in You can write a You must use the
new replacement abstract class as-is for
module for an the code base, with all its
interface that attendant baggage, good
contains not one or bad. The abstract class
stick of code in author has imposed
common with structure on you.
the existing Depending on the
implementations. cleverness of the author
When you of the abstract class, this
implement the may be good or bad.
interface, you Another issue that's
start from important is what I call
scratch without "heterogeneous vs.
any default homogeneous." If
implementation. implementors/subclasses
You have to are homogeneous, tend
obtain your tools towards an abstract base
from other class. If they are
classes; nothing heterogeneous, use an
comes with the interface. (Now all I
interface other have to do is come up
than a few with a good definition of
constants. This hetero/homogeneous in
gives you this context.) If the
freedom to various objects are all of-
implement a a-kind, and share a
radically common state and
behavior, then tend
towards a common base
different internal class. If all they share is
design. a set of method
signatures, then tend
towards an interface.
If all the various
If the various
implementations
implementations are all
share is the
of a kind and share a
Homogeneity method
common status and
signatures, then
behavior, usually an
an interface
abstract class works best.
works best.
If your client
code talks only Just like an interface, if
in terms of an your client code talks
interface, you only in terms of an
can easily abstract class, you can
Maintenance
change the easily change the
concrete concrete implementation
implementation behind it, using a factory
behind it, using a method.
factory method.
Speed Slow, requires Fast
extra indirection
to find the
corresponding
method in the
actual class.
Modern JVMs
are discovering
ways to reduce
this speed
penalty.
The constant
declarations in
an interface are
You can put shared code
all presumed
into an abstract class,
public static
where you cannot into an
final, so you may
interface. If interfaces
leave that part
want to share code, you
out. You can't
will have to write other
call any methods
bubblegum to arrange
to compute the
Terseness that. You may use
initial values of
methods to compute the
your constants.
initial values of your
You need not
constants and variables,
declare
both instance and static.
individual
You must declare all the
methods of an
individual methods of an
interface
abstract class abstract.
abstract. They
are all presumed
so.
Adding If you add a new If you add a new method
functionality method to an to an abstract class, you
interface, you have the option of
must track down providing a default
all implementation of it.
implementations Then all existing code
of that interface
in the universe
and provide
will continue to work
them with a
without change.
concrete
implementation
of that method.
see the code
interface ICommon
{
int getCommon();
}
interface ICommonImplements1:ICommon
{
}
interface ICommonImplements2:ICommon
{
}
public class
a:ICommonImplements1,ICommonImplements2
{
}
How to implement getCommon method in class a? Are you
seeing any problem in the implementation?
Ans:
public class a:ICommonImplements1,ICommonImplements2
{
public int getCommon()
{
return 1;
}
}
interface IWeather
{
void display();
}
public class A:IWeather
{
public void display()
{
MessageBox.Show("A");
}
}
public class B:A
{
}
public class C:B,IWeather
{
public void display()
{
MessageBox.Show("C");
}
}
When I instantiate C.display(), will it work?
interface IPrint
{
string Display();
}
interface IWrite
{
string Display();
}
class PrintDoc:IPrint,IWrite
{
//Here is implementation
}
how to implement the Display in the class printDoc (How to
resolve the naming Conflict) A: no naming conflicts
class PrintDoc:IPrint,IWrite
{
public string Display()
{
return "s";
}
}
interface IList
{
int Count { get; set; }
}
interface ICounter
{
void Count(int i);
}
interface IListCounter: IList, ICounter {}
class C
{
void Test(IListCounter x)
{
x.Count(1); // Error
x.Count = 1; // Error
((IList)x).Count = 1; // Ok, invokes
IList.Count.set
((ICounter)x).Count(1); // Ok, invokes
ICounter.Count
}
}
Write one code example for compile time binding and one for
run time binding? What is early/late binding?
An object is early bound when it is assigned to a variable
declared to be of a specific object type. Early bound objects
allow the compiler to allocate memory and perform other
optimizations before an application executes.
' Create a variable to hold a new object.
Dim FS As FileStream
' Assign a new object to the variable.
FS = New FileStream("C:\tmp.txt", FileMode.Open)
By contrast, an object is late bound when it is assigned to a
variable declared to be of type Object. Objects of this type can
hold references to any object, but lack many of the advantages
of early-bound objects.
Dim xlApp As Object
xlApp = CreateObject("Excel.Application")
Can you explain what inheritance is and an example of when
you might use it?
How can you write a class to restrict that only one object of this
class can be created (Singleton class)?
(Access specifiers)
What are the access-specifiers available in c#?
Private, Protected, Public, Internal, Protected Internal.
Explain about Protected and protected internal, “internal”
access-specifier?
protected - Access is limited to the containing class or types
derived from the containing class.
internal - Access is limited to the current assembly.
protected internal - Access is limited to the current assembly or
types derived from the containing class.

(Constructor / Destructor)
Difference between type constructor and instance constructor?
What is static constructor, when it will be fired? And what is its
use?
(Class constructor method is also known as type constructor or
type initializer)
Instance constructor is executed when a new instance of type is
created and the class constructor is executed after the type is
loaded and before any one of the type members is accessed. (It
will get executed only 1st time, when we call any static
methods/fields in the same class.) Class constructors are used for
static field initialization. Only one class constructor per type is
permitted, and it cannot use the vararg (variable argument)
calling convention.
A static constructor is used to initialize a class. It is called
automatically to initialize the class before the first instance is
created or any static members are referenced.
What is Private Constructor? and it’s use? Can you create
instance of a class which has Private Constructor?
A: When a class declares only private instance constructors, it is
not possible for classes outside the program to derive from the
class or to directly create instances of it. (Except Nested classes)
Make a constructor private if:
- You want it to be available only to the class itself. For example,
you might have a special constructor used only in the
implementation of your class' Clone method.
- You do not want instances of your component to be created.
For example, you may have a class containing nothing but
Shared utility functions, and no instance data. Creating instances
of the class would waste memory.
I have 3 overloaded constructors in my class. In order to avoid
making instance of the class do I need to make all constructors
to private?
(yes)
Overloaded constructor will call default constructor internally?
(no)
What are virtual destructors?
Destructor and finalize
Generally in C++ the destructor is called when objects gets
destroyed. And one can explicitly call the destructors in C++.
And also the objects are destroyed in reverse order that they are
created in. So in C++ you have control over the destructors.
In C# you can never call them, the reason is one cannot destroy
an object. So who has the control over the destructor (in C#)? it's
the .Net frameworks Garbage Collector (GC). GC destroys the
objects only when necessary. Some situations of necessity are
memory is exhausted or user explicitly calls
System.GC.Collect() method.
Points to remember:
1. Destructors are invoked automatically, and cannot be invoked
explicitly.
2. Destructors cannot be overloaded. Thus, a class can have, at
most, one destructor.
3. Destructors are not inherited. Thus, a class has no destructors
other than the one, which may be declared in it.
4. Destructors cannot be used with structs. They are only used
with classes.
5. An instance becomes eligible for destruction when it is no
longer possible for any code to use the instance.
6. Execution of the destructor for the instance may occur at any
time after the instance becomes eligible for destruction.
7. When an instance is destructed, the destructors in its
inheritance chain are called, in order, from most derived to least
derived.
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpguide/html/cpconfinalizemethodscdestructors.asp
What is the difference between Finalize and Dispose (Garbage
collection)
Class instances often encapsulate control over resources that are
not managed by the runtime, such as window handles (HWND),
database connections, and so on. Therefore, you should provide
both an explicit and an implicit way to free those resources.
Provide implicit control by implementing the protected Finalize
Method on an object (destructor syntax in C# and the Managed
Extensions for C++). The garbage collector calls this method at
some point after there are no longer any valid references to the
object.
In some cases, you might want to provide programmers using an
object with the ability to explicitly release these external
resources before the garbage collector frees the object. If an
external resource is scarce or expensive, better performance can
be achieved if the programmer explicitly releases resources
when they are no longer being used. To provide explicit control,
implement the Dispose method provided by the IDisposable
Interface. The consumer of the object should call this method
when it is done using the object. Dispose can be called even if
other references to the object are alive.
Note that even when you provide explicit control by way of
Dispose, you should provide implicit cleanup using the Finalize
method. Finalize provides a backup to prevent resources from
permanently leaking if the programmer fails to call Dispose.
What is close method? How its different from Finalize &
Dispose?
**
What is boxing & unboxing?
What is check/uncheck?
What is the use of base keyword? Tell me a practical example
for base keyword’s usage?
What are the different .net tools which u used in projects?
try
{
...
}
catch
{
...//exception occurred here. What'll happen?
}
finally
{
..
}
Ans : It will throw exception.
What will do to avoid prior case?
Ans:
try
{
try
{
...
}
catch
{
...
//exception occurred here.
}
finally
{
...
}
}
catch
{
...
}
finally
{
...
}
try
{
...
}
catch
{
...
}
finally
{
..
}
Will it go to finally block if there is no exception happened?
Ans: Yes. The finally block is useful for cleaning up any
resources allocated in the try block. Control is always passed to
the finally block regardless of how the try block exits.
Is goto statement supported in C#? How about Java?
Gotos are supported in C#to the fullest. In Java goto is a
reserved keyword that provides absolutely no functionality.
What’s different about switch statements in C#?
No fall-throughs allowed. Unlike the C++ switch statement, C#
does not support an explicit fall through from one case label to
another. If you want, you can use goto a switch-case, or goto
default.
case 1:
cost += 25;
break;
case 2:
cost += 25;
goto case 1;

(ADO.NET)
Advantage of ADO.Net?
ADO.NET Does Not Depend On Continuously Live
Connections
Database Interactions Are Performed Using Data Commands
Data Can Be Cached in Datasets
Datasets Are Independent of Data Sources
Data Is Persisted as XML
Schemas Define Data Structures
How would u connect to database using .NET?
SqlConnection nwindConn = new SqlConnection("Data
Source=localhost; Integrated Security=SSPI;" +
"Initial Catalog=northwind");
nwindConn.Open();
What are relation objects in dataset and how & where to use
them?
In a DataSet that contains multiple DataTable objects, you can
use DataRelation objects to relate one table to another, to
navigate through the tables, and to return child or parent rows
from a related table. Adding a DataRelation to a DataSet adds,
by default, a UniqueConstraint to the parent table and a
ForeignKeyConstraint to the child table.
The following code example creates a DataRelation using two
DataTable objects in a DataSet. Each DataTable contains a
column named CustID, which serves as a link between the two
DataTable objects. The example adds a single DataRelation to
the Relations collection of the DataSet. The first argument in the
example specifies the name of the DataRelation being created.
The second argument sets the parent DataColumn and the third
argument sets the child DataColumn.
custDS.Relations.Add("CustOrders",
custDS.Tables["Customers"].Columns["CustID"],
custDS.Tables["Orders"].Columns["CustID"]);

OR

private void CreateRelation()


{
// Get the DataColumn objects from two DataTable objects in a
DataSet.
DataColumn parentCol;
DataColumn childCol;
// Code to get the DataSet not shown here.
parentCol = DataSet1.Tables["Customers"].Columns["CustID"];
childCol = DataSet1.Tables["Orders"].Columns["CustID"];
// Create DataRelation.
DataRelation relCustOrder;
relCustOrder = new DataRelation("CustomersOrders",
parentCol, childCol);
// Add the relation to the DataSet.
DataSet1.Relations.Add(relCustOrder);
}
Difference between OLEDB Provider and SqlClient ?
Ans: SQLClient .NET classes are highly optimized for the .net /
sqlserver combination and achieve optimal results. The
SqlClient data provider is fast. It's faster than the Oracle
provider, and faster than accessing database via the OleDb layer.
It's faster because it accesses the native library (which
automatically gives you better performance), and it was written
with lots of help from the SQL Server team.
What are the different namespaces used in the project to connect
the database? What data providers available in .net to connect to
database?
System.Data.OleDb – classes that make up the .NET Framework
Data Provider for OLE DB-compatible data sources. These
classes allow you to connect to an OLE DB data source, execute
commands against the source, and read the results.
System.Data.SqlClient – classes that make up the .NET
Framework Data Provider for SQL Server, which allows you to
connect to SQL Server 7.0, execute commands, and read results.
The System.Data.SqlClient namespace is similar to the
System.Data.OleDb namespace, but is optimized for access to
SQL Server 7.0 and later.
System.Data.Odbc - classes that make up the .NET Framework
Data Provider for ODBC. These classes allow you to access
ODBC data source in the managed space.
System.Data.OracleClient - classes that make up the .NET
Framework Data Provider for Oracle. These classes allow you to
access an Oracle data source in the managed space.
Difference between DataReader and DataAdapter / DataSet and
DataAdapter?
You can use the ADO.NET DataReader to retrieve a read-only,
forward-only stream of data from a database. Using the
DataReader can increase application performance and reduce
system overhead because only one row at a time is ever in
memory.
After creating an instance of the Command object, you create a
DataReader by calling Command.ExecuteReader to retrieve
rows from a data source, as shown in the following example.
SqlDataReader myReader = myCommand.ExecuteReader();
You use the Read method of the DataReader object to obtain a
row from the results of the query.
while (myReader.Read())
Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0),
myReader.GetString(1));
myReader.Close();
The DataSet is a memory-resident representation of data that
provides a consistent relational programming model regardless
of the data source. It can be used with multiple and differing
data sources, used with XML data, or used to manage data local
to the application. The DataSet represents a complete set of data
including related tables, constraints, and relationships among the
tables. The methods and objects in a DataSet are consistent with
those in the relational database model. The DataSet can also
persist and reload its contents as XML and its schema as XML
Schema definition language (XSD) schema.
The DataAdapter serves as a bridge between a DataSet and a
data source for retrieving and saving data. The DataAdapter
provides this bridge by mapping Fill, which changes the data in
the DataSet to match the data in the data source, and Update,
which changes the data in the data source to match the data in
the DataSet. If you are connecting to a Microsoft SQL Server
database, you can increase overall performance by using the
SqlDataAdapter along with its associated SqlCommand and
SqlConnection. For other OLE DB-supported databases, use the
DataAdapter with its associated OleDbCommand and
OleDbConnection objects.
Which method do you invoke on the DataAdapter control to
load your generated dataset with data?
Fill()
Explain different methods and Properties of DataReader which
you have used in your project?
Read
GetString
GetInt32
while (myReader.Read())
Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0),
myReader.GetString(1));
myReader.Close();
What happens when we issue Dataset.ReadXml command?
Reads XML schema and data into the DataSet.
In how many ways we can retrieve table records count? How to
find the count of records in a dataset?
foreach(DataTable thisTable in myDataSet.Tables){
// For each row, print the values of each column.
foreach(DataRow myRow in thisTable.Rows){
How to check if a datareader is closed or opened?
IsClosed()
What happens when u try to update data in a dataset in .NET
while the record is already deleted in SQL SERVER as backend?
OR What is concurrency? How will you avoid concurrency
when dealing with dataset? (One user deleted one row after that
another user through his dataset was trying to update same row.
What will happen? How will you avoid the problem?)
**
How do you merge 2 datasets into the third dataset in a simple
manner? OR If you are executing these statements in
commandObject. "Select * from Table1;Select * from Table2”
how you will deal result set?
**
How do you sort a dataset?
**
If a dataset contains 100 rows, how to fetch rows between 5 and
15 only?
**
Differences between dataset.clone and dataset.copy?
Clone - Copies the structure of the DataSet, including all
DataTable schemas, relations, and constraints. Does not copy
any data.
Copy - Copies both the structure and data for this DataSet.
What is the use of parameter object?
**
How to generate XML from a dataset and vice versa?
**
What is method to get XML and schema from Dataset?
ans: getXML () and get Schema ()
How do u implement locking concept for dataset?
Frequently Asked Questions About Visual Basic .NET
Q. What is the name of the new version of Visual Basic?
A. The version of Visual Basic following Visual Basic 6.0 is
Visual Basic .NET.
Q. What are the primary benefits of moving to Visual
Basic .NET today for Visual Basic 6.0 developers?
A. Visual Basic .NET was built to empower today's Visual Basic
developers with new levels of productivity and power. Visual
Basic .NET solves the most challenging issues facing Visual
Basic developers, from application deployment to Microsoft
Windows®-based and Web-based application development to
data access. Some of the new features in Visual Basic .NET
include XCOPY Deployment, which allows applications to be
deployed simply by copying files into the target directory,
Auto-download Deployment, which enables developers to
deploy Windows-based applications as easily as deploying a
Web page, and Control Anchoring, which eliminates the need
to write complex form resize code. Visual Basic .NET also
includes improved Microsoft IntelliSense® statement
completion and strongly typed Microsoft ADO.NET data
access programming. With Visual Basic .NET, you build
robust applications of all types more rapidly, with fewer
errors, and deploy them seamlessly.
Q. Can I use Visual Basic 6.0 and Visual Basic .NET on the
same computer?
A. Yes, you can install Visual Basic .NET on a computer that is
running Visual Basic 6.0 and use both, system requirements
permitting. Both the design-time environments and
applications created with Visual Basic 6.0 and Visual
Basic .NET will run side-by-side on the same computer
seamlessly.
Q. Why have you updated the Visual Basic language in Visual
Basic .NET?
A. Visual Basic has always been on the cutting edge. With the
introduction of the Microsoft .NET Framework, we wanted to
ensure that Visual Basic remains on the cutting edge and
provide Visual Basic developers with unprecedented
programming power, simplicity, and access to the platform.
These design goals drove the language Visual Basic .NET.
While the Visual Basic language has been updated and
enhanced in Visual Basic .NET, the vast majority of language
syntax and semantics will be immediately familiar to today's
Visual Basic developers.

For more information on the language enhancements in


Visual Basic .NET, please see Upgrading to Visual
Basic .NET.
Q. What is the Visual Basic .NET Upgrade Wizard?
A. The Visual Basic .NET Upgrade Wizard comes as part of
Visual Studio .NET Professional, Enterprise Developer, and
Enterprise Architect Editions. It enables you to upgrade
existing Visual Basic projects to Visual Basic .NET in order
to take advantage of all the benefits of working on the .NET
Framework.
Q. What is the .NET Framework?
A. The .NET Framework is a new programming model designed
to simplify application development, provide seamless
integration in the highly distributed environment of the
Internet, and deliver new levels of programming power and
flexibility to Visual Basic developers. All applications written
in Visual Basic .NET execute within the context of the .NET
Framework and can leverage the full power of the rich classes
provided as part of the .NET Framework. In addition, the
.NET Framework provides a consistent programming model
that enables Visual Basic .NET developers to easily share and
reuse code assets written in any of the more than 20
programming languages in the .NET Framework.
Q. With the changes to the Visual Basic language, how can I best
preserve my existing Visual Basic investments?
A. Microsoft is dedicated to ensuring the viability of existing
Visual Basic investments. We have implemented a number of
features and designs in Visual Basic .NET to ensure that
existing investments will carry forward. These include:
• COM interoperability
A rich, high-performance interoperability layer that enables
you to have seamless bidirectional communication between
Visual Basic .NET and Visual Basic 6.0 components
without the need to rewrite a single line of Visual Basic 6.0
code.
• Semantic consistency
Visual Basic 6.0 and Visual Basic .NET provide high levels
of semantic consistency within the language to ensure that
the vast majority of the code you have written in Visual
Basic 6.0 will have the same semantic meaning in Visual
Basic .NET.
• Incremental migration
Using Component Object Model (COM) interoperability,
you can upgrade your project component-by-component
over time to achieve a smooth, incremental upgrade
process.
• The Visual Basic .NET Upgrade Wizard
Provided as part of Visual Studio .NET Professional,
Enterprise Developer, and Enterprise Architect, the
Upgrade Wizard upgrades up to 95 percent of your existing
Visual Basic 6.0 code to Visual Basic .NET. This enables
you to take full advantage of new features in Visual
Basic .NET and the .NET Framework.
Q. Should I plan to upgrade all of my Visual Basic 6.0 code to
Visual Basic .NET?
A. In some scenarios, you may decide not to upgrade Visual
Basic 6.0 code to Visual Basic .NET. Where Visual Basic 6.0
code is deployed, running, and in "maintenance" mode, it may
be best to simply communicate with that code from new
Visual Basic .NET components using COM interoperability.
This enables you to build new applications using Visual
Basic .NET without the need to rewrite existing components
written in Visual Basic 6.0.
Q. Does Visual Basic .NET still enable me to build rich desktop
applications?
A. Absolutely. Visual Basic .NET provides the most
comprehensive, productive environment for building rich
desktop applications. A new forms package called Windows
Forms enables Visual Basic developers to build desktop
applications in less time, with enhanced power, easy
deployment, and improved maintainability. New features in
Windows Forms eliminate the need to write complex resize
code and make application deployment as easy as copying
files into the target directory. Visual Basic .NET provides the
easiest path to Windows Forms development, enabling Visual
Basic developers to use their existing skills to implement the
next generation of the smart client.
Q. What other types of applications does Visual Basic .NET
enable me to build?
A. Visual Basic developers have access to a much broader range
of applications in Visual Basic .NET than in previous versions
of the Visual Basic tool set. By employing the same skills that
you use to develop Windows-based applications, you can now
build broad-reach, thin-client, Web-based applications as well
as applications that target mobile devices. In addition, now
Visual Basic .NET developers easily can create true Microsoft
Windows NT® Services using the new Windows Service
project template and applications that target the Windows
console using the Console Application project template. In
addition, Visual Basic .NET enables you to visually compose
server-side business logic components using the Server
Explorer and Visual Component Designer. Finally, now
developers using Visual Basic .NET easily can build
Windows services and console applications using the new
application templates.
Q. What are the differences between Visual Basic .NET and
Visual C# .NET?
A. Visual Basic .NET and Microsoft Visual C#™ .NET have
been designed for the Visual Basic and Microsoft Visual
C++® communities, respectively. Visual Basic .NET was
built around the concept of empowering Visual Basic
developers with unprecedented power and productivity in
solving today’s application development problems more
effectively and efficiently—from desktop and Web-based
application development to ending deployment and
versioning problems, informally referred to as "DLL hell".
Visual C# was driven by developers within the C++
community who wanted more productivity in building their
applications. Visual Basic .NET and Visual C# .NET contain
a very similar set of capabilities, and applications built in
these two languages will run at the same speed. However,
Visual Basic .NET and Visual C# .NET differ considerably in
their user experiences. Because Visual Basic .NET targets
Visual Basic developers, it incorporates the concepts and
constructs familiar to Visual Basic developers, such as Visual
Basic language syntax and semantics, case-insensitive coding,
a powerful background compiler, and the option to do late-
binding. Similarly, Visual C# incorporates features familiar to
C++ developers, such as unsafe code.
Q. Will Microsoft produce an unmanaged update to the Visual
Basic compiler?
A. Microsoft will continue to release service packs for Visual
Basic 6.0 to provide bug fixes and to increase overall product
stability.
Q. What role does Visual InterDev play in Visual Studio .NET?
A. Many of the benefits of Microsoft Visual InterDev® have
been incorporated throughout Visual Studio .NET, enabling
developers of all backgrounds to quickly build Web-based
applications. In Visual Studio .NET, existing Visual InterDev
and Visual Basic developers can build Web-based
applications using a new forms package called Web Forms.
The Web Forms package enables the construction of Web-
based applications using the same drag-and-drop techniques
and code-behind forms that Visual Basic developers have
used for years to build rich desktop applications.
Q. Do ActiveX controls run within the context of Visual
Basic .NET?
A. Yes. Visual Basic .NET employs a new package for building
desktop applications called Windows Forms. The Windows
Forms package was designed to be an excellent container for
existing Microsoft ActiveX® controls to ensure that current
investments will be preserved.
Q. Who is currently using Visual Basic .NET?
A. More and more organizations of all sizes with Visual Basic
developers of all skill levels are recognizing the broadly
expanded feature set and new productivity features in Visual
Basic .NET and are implementing their critical software
applications using Visual Basic .NET. This was evident even
during the beta release of Visual Basic .NET, with customers
such as Verizon Wireless, Zagat Survey, DataReturn, and
many others building XML Web services, thin-client Web-
based applications, rich desktop applications, as well as agile
mobile applications using Visual Basic .NET.
Q. How can I set up the environment so that it uses the key
bindings I am used to?
A. On the Visual Studio .NET Start Page, click My Profile.
Under Profile, select Visual Basic Developer.
Q. Where are the Professional and Enterprise versions editions
of Visual Basic .NET and Microsoft Visual C++ .NET?
A. The functionality previously available in Professional and
Enterprise versions of the individual language products is
now available in the Professional and Enterprise versions of
Visual Studio .NET. In addition, a new Visual Studio .NET
Enterprise Architect Edition is available with tools
specifically designed for software architects building
enterprise software, including Microsoft Visio® Enterprise
Architect Edition.

1. What is IUnknown? What methods are provided by


IUnknown? It is a generally good idea to have an answer
for this question if you claim you know COM in your
resume. Otherwise, you may consider your interview failed
at this point. IUnknown is the base interface of COM. All
other interfaces must derive directly or indirectly from
IUnknown. There are three methods in that interface:
AddRef, Release and QueryInterface.
2. What are the purposes of AddRef, Release and
QueryInterface functions? AddRef increments reference
count of the object, Release decrements reference counter
of the object and QueryInterface obtains a pointer to the
requested interface.
3. What should QueryInterface functions do if requested
object was not found? Return E_NOINTERFACE and
nullify its out parameter.
4. How can would you create an instance of the object in
COM? Well, it all depends on your project. Start your
answer from CoCreateInstance or CoCreateInstanceEx,
explain the difference between them. If interviewer is still
not satisfied, you’ll have to explain the whole kitchen
behind the scenes, including a difference between local
server and inproc server, meaning and mechanism of class
factory, etc. You may also mention other methods of object
creation like CoGetInstanceFromFile, but discussion will
likely turn to discussion of monikers then.
5. What happens when client calls CoCreateInstance?
Again, all depends on the level of detail and expertise of
interviewer. Start with simple explanation of class object
and class factory mechanism. Further details would depend
on a specific situation.
6. What the limitations of CoCreateInstance? Well, the
major problems with CoCreateInstance is that it is only
able to create one object and only on local system. To
create a remote object or to get several objects, based on
single CLSID, at the same time, one should use
CoCreateInstanceEx.
7. What is aggregation? How can we get an interface of
the aggregated object? Aggregation is the reuse
mechanism, in which the outer object exposes interfaces
from the inner object as if they were implemented on the
outer object itself. This is useful when the outer object
would always delegate every call to one of its interfaces to
the same interface in the inner object. Aggregation is
actually a specialized case of containment/delegation, and
is available as a convenience to avoid extra implementation
overhead in the outer object in these cases. We can get a
pointer to the inner interface, calling QueryInterface of the
outer object with IID of the inner interface.
8. C is aggregated by B, which in turn aggregated by A.
Our client requested C. What will happen?
QueryInterface to A will delegate request to B which, in
turn, will delegate request for the interface to C. This
pointer will be returned to the client.
9. What is a moniker ? An object that implements the
IMoniker interface. A moniker acts as a name that uniquely
identifies a COM object. In the same way that a path
identifies a file in the file system, a moniker identifies a
COM object in the directory namespace.
10. What’s the difference, if any, between OLE and COM?
OLE is build on top of COM. The question is not strict,
because OLE was built over COM for years, while COM as
a technology was presented by Microsoft a few years ago.
You may mention also that COM is a specification, while
OLE is a particular implementation of this specification,
which in today’s world is not exactly true as well, because
what people call COM today is likely implementation of
COM spec by Microsoft.
11. What’s the difference between COM and DCOM?
Again, the question does not require strict answer. Any
DCOM object is yet a COM object (DCOM extends COM)
and any COM object may participate in DCOM
transactions. DCOM introduced several
improvements/optimizations for distributed environment,
such as MULTI_QI (multiple QueryInterface()), security
contexts etc. DCOM demonstrated importance of surrogate
process (you cannot run in-proc server on a remote
machine. You need a surrogate process to do that.) DCOM
introduced a load balancing.
12. What is a dual interface? Dual interface is one that
supports both - IDispatch interface and vtbl-based interface.
Therefore, it might be used in scripting environment like
VBScript and yet to use power and speed of vtbl-based
interface for non-scripting environment. Discussion then
may easily transform into analyzing of dual interface
problems - be prepared to this twist.
13. Can you have two dual interfaces in one class? Yes. You
may have two dual interfaces in one class, but only one of
them may be default. The bottom line is that you cannot
work with two dual interfaces at the same time due to
nature of dual interface! To support two dual interfaces in
VB you would write something like:
14. dim d1 as IDualInterface1
15. dim d2 as IDualInterface2
16. set d1 = new MyClassWithTwoDuals
17. set d2 = d1

In ATL’s class you would have to use macro


COM_INTERFACE_ENTRY2(IDispatch,
IDualInterface1), to distinguish between different dual
interfaces.
18. What is marshalling by value? Some objects can
essentially be considered static: regardless of which
methods are called, the state of the object does not change.
Instead of accessing such an object remotely, it is possible
to copy the static state of the object and create a new object
with the same state information on the caller side. The
caller won’t be able to notice the difference, but calls will
be more efficient because they do not involve network
round trips. This is called “marshaling by value”.
19. What is a multi-threaded apartment (MTA)? Single-
threaded apartment (STA)? This is pretty difficult question
to describe shortly. Anyway, apartments were introduced by
Microsoft in NT 3.51 and late Windows 95 to isolate the
problem of running legacy non-thread safe code into
multithreaded environment. Each thread was
“encapsulated” into so called single-threaded apartment.
The reason to create an object in apartment is thread-safety.
COM is responsible synchronize access to the object even
if the object inside of the apartment is not thread-safe.
Multithreaded apartments (MTA, or free threading
apartment) were introduced in NT 4.0. Idea behind MTA is
that COM is not responsible to synchronize object calls
between threads. In MTA the developer is responsible for
that. See “Professional DCOM Programming” of Dr.
Grimes et al. or “Essential COM” of Don Box for the
further discussion on this topic.
20. Let’s assume we have object B and aggregated object C
(in-proc server), created by B. Can you access any
interface of B from C? What’s the difference between
aggregated and contained objects? Yes, you can. This is
fundamental postulate of COM: “If you can get there from
here, you can get there from anywhere”, i.e. QI’ing for
IUnknown you may proceed and to get a pointer to any
other interface, supported by the object. Aggregated object
exposes its interface directly, without visible intervention of
the object container. Contained object is created within the
object container and its interfaces might be altered or
filtered by the object container.
21. What is ROT ? GIT ? Count pros and cons of both. By
definition, running object table (ROT) is a globally
accessible table on each computer that keeps track of all
COM objects in the running state that can be identified by a
moniker. Moniker providers register an object in the table,
which increments the object’s reference count. Before the
object can be destroyed, its moniker must be released from
the table. Global Interface Table (GIT) allows any
apartment (either single- or multi-threaded) in a process to
get access to an interface implemented on an object in
any other apartment in the process.
22. If you have an object with two interfaces, can you
custom marshal one of them? No! The decision to use
custom marshaling is an all-or-nothing decision; an object
has to custom marshal all its interfaces or none of them.
23. Is there a way to register in-proc server without
regsvr32.exe? Yes. Call DllRegisterServer() from the
client. Do not forget to call DLLUnregisterServer() from
the same client. You may also use Registrar object for the
same purpose or use direct manipulation of the windows
registry.
24. What is VARIANT? Why and where would you use it?
VARIANT is a huge union containing automation type.
This allows easy conversion of one automation type to
another. The biggest disadvantage of VARIANT is size of
the union.
25. How can you guarantee that only remote server is ever
created by a client? Create an object (call
CoCreateObjectEx()) with CLSCTX_REMOTE_SERVER
flag.
26. What is __declspec(novtable)? Why would you need
this? __declspec(novtable) is a Microsoft’s compiler
optimization. The main idea of this optimization is to strip
the vtable initialization code from abstract class (for
abstract class the vtable is empty, while it is initialized in
contructor) MSDN has an article on this topic.
27. What is an IDL? IDL stands for Interface Definition
Language. IDL is the language to describe COM interfaces.
28. What is In-proc? In-proc is in-process COM object, i.e.
COM object that implemented as DLL and supposed to be
hosted by a container. When you have to instantiate the in-
proc object remotely, you may use DLLHost.exe
application that was design specially for this purpose.
29. What is OLE? OLE is an object and embedding first
implementation of COM spec available from MS before
COM was officially named COM.
30. Give examples of OLE usage. The most famous examples
are probably drag and drop and structured storage
implementations.
31. What are 2 storage types for composite document?
Storage and Stream.
32. Is .doc document a compound document? Is it a
structured storage? Compound document is a document
that contains information about other documents hosted in
this document. All office documents _may_ be compound
documents, but may be not. Word documents from version
6.0 and up are stored as structured storage.

1. How do you register a component? Expected answer:


Compiling the component, running REGSVR32
MyDLL.dll
2. Name and explain the different compatibility types
when creating a COM component. Expected answer: No
Compatibility ? New GUID created, references from other
components will not workProject Compatibility ? Default
for a new component <Not as critical to mention this
one>Binary Compatibility ? GUID does not change,
references from other components will work
3. Why iss it important to use source control software for
source code? Expected answer: Modification history.Code
ownership: Multiple people can not modify the same code
at the same time.
4. What two methods are called from the ObjectContext
object to inform MTS that the transaction was
successful or unsuccessful? Expected answer:
SetComplete and SetAbort.
5. What is the tool used to configure the port range and
protocols for DCOM communications? Expected
answer: DCOMCONFIG.EXE
6. What does Option Explicit refer to? Expected answer:
All variables must be declared before use. Their type is not
required.
7. What are the different ways to Declare and Instantiate
an object in Visual Basic 6? Expected answer: Dim obj as
OBJ.CLASS with eitherSet obj = New OBJ.CLASS orSet
obj = CreateObject(?OBJ.CLASS?) orSet obj = GetObject(
,? OBJ.CLASS?)orDim obj as New OBJ.CLASS
8. Name the four different cursor types in ADO and
describe them briefly. Expected answer: The cursor types
are listed from least to most resource intensive.Forward
Only ? Fastest, can only move forward in recordset Static ?
Can move to any record in the recordset. Data is static and
never changes.KeySet ? Changes are detectable, records
that are deleted by other users are unavailable, and records
created by other users are not detectedDynamic ? All
changes are visible.
9. Name the four different locking type in ADO and
describe them briefly. Expected answer:
LockPessimistic ? Locks the row once after any edits
occur.LockOptimistic ? Locks the row only when Update is
called.LockBatchOptimistic ? Allows Batch
Updates.LockReadOnly ? Read only. Can not alter the data.
10. Describe Database Connection pooling (relative to MTS
) Expected answer: This allows MTS to reuse database
connections. Database connections are put to ?sleep? as
opposed to being created and destroyed and are activated
upon request.
11. What are the ADO objects? Explain them. Provide a
scenario using three of them to return data from a
database. Expected answer: Connection ? Connects to a
data source; contains the Errors collectionCommand ?
Executes commands to the data source. Is the only object
that can accept parameters for a stored procedure.Recordset
? The set of data returned from the database.Scenario:
There are many possibilities. The most likely is as
follows:Dim conn As ADODB.ConnectionDim rs As
ADODB.RecordsetDim Cmd As
ADODB.Commandconn.ConnectionString = ?
CONNECTION STRING?conn.OpenSet
Cmd.ActiveConnection = connCmd.CommandText = ?SQL
STATEMENT?Set rs = Cmd.ExecuteSet
rs.ActiveConnection = Nothingconn.Close
12. Under the ADO Command Object, what collection is
responsible for input to stored procedures? Expected
answer: The Parameters collection.
13. What are some benefits of using MTS? Expected
answer: Database Pooling, Transactional operations,
Deployment, Security, Remote Execution.
14. What is the benefit of wrapping database calls into
MTS transactions? Expected answer: If database calls are
made within the context of a transaction, aborting the
transaction will undo and changes that occur within that
transaction. This removes the possibility of stranded, or
partial data.
15. Describe and In Process vs. Out of Process component.
Which is faster? Expected answer:An in-process
component is implemented as a DLL, and runs in the same
process space as its client app, enabling the most efficient
communication between client and component.Each client
app that uses the component starts a new instance of it.An
out of process component is implemented as an EXE, and
unlike a dll, runs in its own process space. As a result, exe’s
are slower then dll’s because communications between
client and component must be marshalled across process
boundaries. A single instance of an out of process
component can service many clients.
What are the main components of the ADO object model? How
are they used? Expected answer:Connection: Used to make a
connection between your app and an external data source, ie, sql
server.Command: Used to build queries, including user-specific
parameters, to access records from a data source (which are
returned in a Recordset)Recordset:Used to access records
returned from an SQL query. With a recordset, you can navigate
COM interview questions
1. What is IUnknown? What methods are provided by
IUnknown? It is a generally good idea to have an answer
for this question if you claim you know COM in your
resume. Otherwise, you may consider your interview failed
at this point. IUnknown is the base interface of COM. All
other interfaces must derive directly or indirectly from
IUnknown. There are three methods in that interface:
AddRef, Release and QueryInterface.
2. What are the purposes of AddRef, Release and
QueryInterface functions? AddRef increments reference
count of the object, Release decrements reference counter
of the object and QueryInterface obtains a pointer to the
requested interface.

You might also like