Get benefited from interview Q/A and Online Test section. Subscribe to this blog to get updates directly in your mail box.
Best View in Google Crome, Mozilla firefox or IE 7 or above

Friday, May 15, 2009

C# Dotnet Interview questions

This section contains C# Dotnet Interview Questions that I faced in my interviews at the time of job change. Please post your comments here. Also, post your questions to get an answer.

1. What are the features of an object oriented programming language?
Ans: I. Abstraction
II. Encapsulation
III. Polymorphism
IV. Inheritance

2. What is the difference between overloading and overriding in C#?

3. What is the difference between Abstract class and Interface?

4. What is the difference between ref and out?

5. What is Generics in C#? List the advantages.

6. What is advantages of using "using" block?
Ans: Using block is a short cut to try{} finally{} block.
Generally used to define connections. It will dispose the connection object automatically once we come out of using block.

7. What is use of a static constructor?

8. Describe the event delegate model in C#.

9. What are partial classes?

10. what is a sealed class?

11. What is the difference between Array and ArrayList? List the advantages.


Many more to come ....

9 comments:

  1. The difference between Overloading and Overrdiding in C# is as follows :


    OVERLOADING : Here a method is made to perform more than 1 operations.

    Ex: Suppose we have a method called Add(). This method say, by deault performs
    addition of 2 integers. This method can be overloaded to perform addition of
    floating point numbers.

    OVERRIDING : Here, a method's default behavior is changed to perform some other operation.

    ReplyDelete
  2. Thanks MK for posting an answer here.

    ReplyDelete
  3. Your question answers are really helpful. Thanks for providing such a wonderful content.

    ReplyDelete
  4. Sealed class : we can not inherite the class if it is sealed

    ReplyDelete
  5. overloading : it compile time polymorphism. it may or may not comes with inheritance.
    the signature may differ. it differenciate on arguments, type of arguments and no. of arguments passed to function.

    Overriding: it is run time polymorphism. this comes with inheritance. the signature not differs. we can overwrite the method from parent class in derived class.

    ReplyDelete
  6. ref and out: both are same but out requires initialisation before use. the out and ref keywords differ as runtime but same at compile time so methods are not overloaded.

    ReplyDelete
  7. Thanks Shubhangi for posting the answers here.

    ReplyDelete
  8. Partial Class:As the name indicates, partial class definitions can be split up across multiple physical files. To the compiler, this does not make a difference, as all the fragments of the partial class are grouped and the compiler treats it as a single class. One common usage of partial classes is the separation of automatically-generated code from programmer-written code.

    Below is the example of a partial class.

    ReplyDelete
  9. Partial Class



    In this article I will explain what is a partial class? What are the benefits of using partial classes and how to implement partial classes in your C# applications.



    Partial class is a new feature added to C# 2.0 and Visual Studio 2005. It is supported in .NET Framework 2.0. If you are working with .NET 1.0 or 1.1, partial classes may not work.


    It is possible to split the definition of a class or a struct, or an interface over two or more source files. Each source file contains a section of the class definition, and all parts are combined when the application is compiled.



    When working on large projects, spreading a class over separate files allows multiple programmers to work on it simultaneously.



    When working with automatically generated source, code can be added to the class without having to recreate the source file. Visual Studio uses this approach when creating Windows Forms, Web Service wrapper code, and so on. You can create code that uses these classes without having to edit the file created by Visual Studio.



    Benefit of partial classes:



    1) More than one developer can simultaneously write the code for the class.



    2) You can easily write your code (for extended functionality) for a VS.NET generated class. This will allow you to write the code of your own need without messing with the system generated code.



    There are a few things that you should be careful about when writing code for partial classes:

    All the partial definitions must proceeded with the key word "Partial".
    All the partial types meant to be the part of same type must be defined within a same assembly and module.
    Method signatures (return type, name of the method, and parameters) must be unique for the aggregated typed (which was defined partially).
    The partial types must have the same accessibility.
    If any part is sealed, the entire class is sealed.
    If any part is abstract, the entire class is abstract.
    Inheritance at any partial type applies to the entire class.

    I have attached code of the partial classes along with this article. You can open the project and understand the functionality.

    ReplyDelete

  © Blogger templates Shiny by Ourblogtemplates.com 2008

Back to TOP