OOPs INTERVIEW QUESTION & ANSWERS
71. |
What is method overloading? |
|
Method overloading is having methods with same name but carrying different signature, this is useful when you want a method to behave differently depending upon a data passed to it. |
72. |
What is the difference between compile time polymorphism and runtime polymorphism? |
|
- Compile time polymorphism is method and operators overloading. It is also called early binding.
- Runtime time polymorphism is done using inheritance and virtual functions. Method overriding is called runtime polymorphism. It is also called late binding.
|
73. |
How is method overriding different from overloading? |
|
When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class. |
74. |
What are the properties of delegates? |
|
- Delegates are like C++ function pointers but are type safe.
- Delegates allow methods to be passed as parameters.
- Delegates can be used to define callback methods.
- Delegates can be chained together; for example, multiple methods can be called on a single event.
|
75. |
What does the keyword virtual declare for a method or property? |
|
The virtual keyword is used to modify a method, property, indexer, or event declaration and allow it to be overridden in a derived class. |