Set - 9

Question 1 :

How do you debug an ASP.NET Web application?

Answer :

Attach the aspnet_wp.exe process to the DbgClr debugger.


Question 2 :

How do you mark a method obsolete?

Answer :

Assuming you've done a "using System;": [Obsolete]
public int Foo() {...}
or [Obsolete("This is a message describing why this method is obsolete")]
public int Foo() {...}
Note: The O in Obsolete is capitalized.


Question 3 :

How is the DLL Hell problem solved in .NET?

Answer :

Assembly versioning allows the application to specify not only the library it needs to run (which was available under Win32), but also the version of the assembly


Question 4 :

What are the ways to deploy an assembly?

Answer :

An MSI installer, a CAB archive, and XCOPY command.


Question 5 :

Why does DllImport not work for me?

Answer :

All methods marked with the DllImport attribute must be marked as public static extern.


Question 6 :

What is a delegate?

Answer :

A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.


Question 7 :

What is the difference between an interface and abstract class?

Answer :

In the interface all methods must be abstract; in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes.


Question 8 :

What is an abstract class?

Answer :

A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over-ridden. Essentially, it is a blueprint for a class without any implementation. 
_break


Question 9 :

Does C# support multiple-inheritance?

Answer :

No.


Question 10 :

Who is a protected class-level variable available to?

Answer :

It is available to any sub-class (a class inheriting this class).


Question 11 :

Can you store multiple data types in System.Array?

Answer :

No.


Question 12 :

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

Answer :

System.Object.

 


Question 13 :

What does the term immutable mean?

Answer :

The data value may not be changed. Note: The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory.


Question 14 :

What's the difference between System.String and System.Text.StringBuilder classes?

Answer :

System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.


Question 15 :

What's the advantage of using System.Text.StringBuilder over System.String? 

Answer :

StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.


Question 16 :

How can you sort the elements of the array in descending order?

Answer :

By calling Sort() and then Reverse() methods.


Question 17 :

What's the .NET collection class that allows an element to be accessed using a unique key?

Answer :

HashTable.


Question 18 :

What class is underneath the SortedList class?

Answer :

A sorted HashTable.


Question 19 :

Will the finally block get executed if an exception has not occurred?

Answer :

Yes.


Question 20 :

What's the C# syntax to catch any possible exception?

Answer :

A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.