OOPs INTERVIEW QUESTION & ANSWERS
51. |
What is sealed class? |
|
Sealed classes are those classes which can not be inherited and thus any sealed class member can not be derived in any other class. A sealed class cannot also be an abstract class. |
52. |
What is an Abstract class? |
|
An abstract class is a special kind of class that cannot be instantiated. It normally contains one or more abstract methods or abstract properties. It provides body to a class. |
53. |
What are the different categories of inheritance? |
|
Inheritance in OOP is of four types :- Single inheritance : Contains one base class and one derived class.
- Hierarchical inheritance : Contains one base class and multiple derived classes of the same base class.
- Multilevel inheritance : Contains a class derived from a derived class.
- Multiple inheritance : Contains several base classes and a derived class.
|
54. |
What is the difference between Class and structures? |
|
- Structures are value types and classes are reference types. So structures use stack
and classes use heap.
- Structures members cannot be declared as protected, but class members can be. You
cannot do inheritance in structures.
- Structures do not require constructors while classes require.
|
55. |
What is static constructor? |
|
When constructors are used to set the value of a type's data at the time of construction, if we want the value of such static data is to be preserved regardless of how many objects of the type are created, we have to define the constructor with static keyword. |