Sunday, August 9, 2009

C# Questions

  • Does C# support multiple-inheritance?

No.

  • Who is a protected class-level variable available to?

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

  • Are private class-level variables inherited?

Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.

  • Describe the accessibility modifier “protected internal”.

It is available to classes that are within the same assembly and derived from the specified base class.

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

System.Object.

  • What does the term immutable mean?

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

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

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

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

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

  • Can you store multiple data types in System.Array?

No.

  • What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?

The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a shallow copy. A shallow copy means the contents (each array element) contains references to the same object as the elements in the original array. A deep copy (which neither of these methods performs) would create a new instance of each element's object, resulting in a different, yet identacle object.

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

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

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

HashTable.

  • What class is underneath the SortedList class?

A sorted HashTable.

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

Yes.

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

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 {}.

  • Can multiple catch blocks be executed for a single try statement?

No. Once the proper catch block processed, control is transferred to the finally block (if there are any).

  • Explain the three services model commonly know as a three-tier application.

Presentation (UI), Business (logic and underlying code) and Data (from storage or other sources).

ASP.net

  • What is ASp.net framework?
The Microsoft .NET Framework is a software framework that can be installed on computers running Microsoft Windows operating systems. It includes a large library of coded solutions to common programming problems and a virtual machine that manages the execution of programs written specifically for the framework. The .NET Framework is a key Microsoft offering and is intended to be used by most new applications created for the Windows platform.

  • What are the advantage of using ASP.net?
  1. They can be executed more quickly as they are compiled by executable portions of a web application
  2. On the fly updates of deployed web application without restarting the server
  3. It simplifies many aspects of windows programming
  4. Its security is high as it is built in security through windows server or through authentication or Authorization methods
  5. Integration wit ADO.net to provide Database access & design tools from within Vs.net
  6. It fully supports mark up language
  7. Automatic state management is there
  • What is the advantages of storing the information on the client side?
  1. Better Scalability: with the server side state management each client that connects to the web server consumes memory in the web server.If the consumers are very high this can be a limitting factor. The client side management helps to rectify this difficulty
  2. Supports Multiple Web Server: In client side management we can distribute the incoming request to multiple web server with no change in your application, so the server needs only to process the request
  • What is the advantages of storing the information on the server side?
  1. Better Security: Client side management can be captured or modified easily, so confidential datas can never be stored in client side
  2. Reduced Bandwidth: If you are using client side management the bandwidth required will b high and the page load time will increase which will potentially increase your cost

  • How a web application works?

On the client side web application is hosted by the browser(IE,Firefox etc). The application user interface takes the form of html pages,that are interpreted and displayed by the client's browser.

On the server side web application runs under Microsoft Internet Information Services(MIIS). The IIS manages the application,passes the request from the client to the application and returns application's response to the client.These requests and responses are passed across the internet using http