About me

Tuesday, September 29, 2015

Best C# Language Interview Questions and Answers

11. Is it possible for a class to inherit the constructor of its base class?

No, a class cannot inherit the constructor of its base class.

12. How is method overriding different from method overloading?

Overriding entails the creation of two or more methods with the same name and same signature in different classes (one of them should be parent class and other should be child).

 Overloading is a concept of using a technique at different places with same name and different signatures within the same class.

 13. What is the difference between a class and a structure?

 Class:

1. A class is a reference type.
2. While instantiating a class, CLR allocates memory for its instance in heap.
3. Classes support inheritance.
4. Variables of a class can be assigned as null.
5. Class can contain constructor/destructor.

 Structure:

1. A structure is a value type.
2. In structure, memory is allocated on stack.
3. Structures do not support inheritance.
4. Structure members cannot have null values.
5. Structure does not require constructor/destructor and members can be initialiazed automatically.

14. What are similarities between a class and a structure.

The most important data structures are structures and classes which are used by programmers to build modular programs by using OOP languages, such as Visual Basic .NET, and Visual C#. The following are some of the similarities between a class and a structure:

• Access specifiers, such as public, private, and protected, are identically used in structures and classes to restrict the access of their data and methods outside their body.
• The access level for class members and struct members, including nested classes and structs, is private by default. Private nested types are not accessible from outside the containing type.
• Both can have constructors, methods, properties, fields, constants, enumerations, events, and event handlers.
• Both structures and classes can implement interfaces to use multiple-inheritance in code.
• Both structures and classes can have constructors with parameter.
• Both structures and classes can have delegates and events.

15. What is a multicast delegate?




 Each delegate object holds reference to a single method. However, it is possible for a delegate object to hold references of and invoke multiple methods. Such delegate objects are called multicast delegates or combinable delegates.

No comments:

Post a Comment