Saturday 15 May 2010

Technical Questions Part 2

Part 1 of the Technical Questions concentrated on the basics of the questions, such as “What is OOP”? Part 2 of this blog is looking at some of the more specific questions I have been asked.

I have not sectioned or categorised the list of questions as I have just gone through them as I remember – I may look at grouping them in the future, but you know what it’s like, just as you start typing another set of questions comes into your head.

Some of the questions also highlight some of the difficulties the questioner has in phrasing the questions. Take for instance a question I was asked a few days ago, “Is XML case sensitive”?

The answer isn’t as simple as the question is asked because it was out of context. XML on its own is NOT case sensitive. It does, however, have to conform to “well formed” document parameters. The case used in the open tag must be identical to that of the closed tag, and a few other rules it must comply with. The question assumes that XML is a program language, such as Java or C# which have different rules over case sensitivity. XML is a text document that has a structure that conforms to a set of rules.

In the case of this type of question it is always good to ask for clarification, explaining what you understand about XML being well formed.

1. In C# what is Boxing and when is it used?
Boxing and unboxing enable value types to be treated as objects. Boxing a value type packages it inside an instance of the Object reference type. This allows the value type to be stored on the garbage collected heap. Unboxing extracts the value type from the object.

In relation to simple assignments, boxing and unboxing are computationally expensive processes. When a value type is boxed, an entirely new object must be allocated and constructed. To a lesser degree, the cast required for unboxing is also expensive computationally.

2. What is the difference between a string and StringBuilder?
Both String and StringBuilder are classes used to handle strings

And then we get into understanding about Mutable and Non-Mutable objects.
string = Non-Mutable, it's contents cannot be altered or length of the string changed without making a new string.

StringBuilder = Mutable, the size and content of the string can be altered in the same memory space without the need to create a new object.

The most common operation with a string is concatenation. This activity has to be performed very efficiently. When we use the "String" object to concatenate two strings, the first string is combined to the other string by creating a new copy in the memory as a string object, and then the old string is deleted. This process is a little long. Hence we say "Strings are immutable".

When we make use of the "StringBuilder" object, the Append method is used. This means, an insertion is done on the existing string. Operation on StringBuilder object is faster than String operations, as the copy is done to the same location. Usage of StringBuilder is more efficient in case large amounts of string manipulations have to be performed.

3. What is an Assembly?
An assembly may be an exe, a dll, an application having an entry point, or a library. It may consist of one or more files. It represents a group of resources, type definitions, and implementation of these types. They may contain references to other assemblies. These resources, types & references are compacted in a block of data called manifest.

4. What is a Session?
The session object is used to store the data specific to a user for the entire length of a user's visit to a website.

5. What is a Thread?
When we want to run one or more instances of a method, we make use of threading.

No comments:

Post a Comment