Monday, April 14, 2008

C# Interview Questions

Can you explain what inheritance is and an example of when you might use it?
Inheritance allows us to extend the functionality of a base class. It is an "Is a"
type of relationship rather than a "Uses" type of relationship (a dalmation IS A
dog which IS A canine which IS A mammal - dalmations inherist from dog which
inherits from canine which inherits from mammal). All child classes retain the
properties and methods of their parent classes but may override them. When you
want to inherit (use the functionality of) another class. Base Class Employee.
A Manager class could be derived from the Employee base class.

Does C# support multiple-inheritance?
No, use interfaces instead.

Can you prevent your class from being inherited by another class?
Yes. The keyword “sealed” will prevent the class from being inherited.

What does the keyword “virtual” declare for a method or property?
The method or property can be overridden.

What's the top .NET class that everything is derived from?
System.Object.

What does it mean that a String is immutable?
Strings cannot be altered. When you alter a string (by adding to it for example),
you are actually creating a new string.

I have to alter a string many times, such as mutliple concatenations,what class should I use?
StringBuilder. It is not immutable and is very efficient.

In a Try - Catch - Finally block, will the finally block execute if an exception
has not occurred? If an Exception has occurred?
Yes and yes.

Whats MSIL, and why should developers need an appreciation of it, if at all?
A. MSIL is the Microsoft Intermediate Language. All .NET compatible
languages will get converted to MSIL.

Explain the three tier or n-Tier model.
Presentation (UI), business (logic and underlying code) and data
(from storage or other sources).

What is SOA?
Service Oriented Architecture. In SOA you create an abstract layer that
your applications use to access various "services" and can aggregate the
services. These services could be databases, web services, message queues
or other sources. The Service Layer provides a way to access these services
that the applications do not need to know how the access is done. For example,
to get a full customer record, I might need to get data from a SGL Server
database, a web service and a message queue. The Service layer hides this from
the calling application. All the application knows is that it asked for a full
customer record. It doesn't know what system or systems it came from or
how it was retrieved.

What is the role of the Data Reader class in ADO.NET connections?
It returns a forward-only, read-only view of data from the data source when
the command is executed.

Is XML case-sensitive?
Yes.

What is the CLR?
Common Language Runtime

Can you explain some differences between an ADO.NET Dataset and
an ADO Recordset? (Or describe some features of a Dataset).
A DataSet can represent an entire relational database in memory,
complete with tables, relations, and views. A DataSet is designed to
work without any continuing connection to the original data source. Data in
a DataSet is bulk-loaded, rather than being loaded on demand. There's no
concept of cursor types in a DataSet. DataSets have no current record pointer
You can use For Each loops to move through the data. You can store many
edits in a DataSet, and write them to the original data source in a single operation.
Though the DataSet is universal, other objects in ADO.NET come in different
versions for different data sources

Name some of the Microsoft Application Blocks. Have you used any?
Which ones?
Examples:
Exception Management
Logging
Data Access
User Interface
Caching Application Block for .NET
Asynchronous Invocation Application Block for .NET
Configuration Management Application Block for .NET
(there are others) We use Exception and Data Access

No comments: