OOPs Interview Question and Answers
41. |
Define static members and methods? |
|
- The members declared with the keyword static is called as static members. It is also called as class variables. These variables are used when we want to have a variable common to all instances of a class.
-
The methods declared with the keyword static is called as static methods. It is also called as Class methods. It can be called without using the object. They are also available for use by other classes.
|
|
|
42. |
What is called abstract method? |
|
- A method that has the keyword abstract in the header of its declaration is said to be an abstract method.
- An abstract method has no implementation. It will be overridden in the derived classes.
- An abstract method is treated as a virtual method.
|
|
|
43. |
Give the advantages of inheritance. |
|
- Reuses the existing code and extends the functionality.
- Add new members to the derived class.
- Can replace the implementation of existing methods by overriding the method.
- Use of override and virtual methods helps to exhibit polymorphic behavior.
|
|
|
44. |
Define polymorphism? |
|
Polymorphism means one name many forms. It is the capability of one object to behave in multiple ways. The polymorphism can be achieved in two ways- Run Time Polymorphism and
- Compile Time Polymorphism
|
|
|
45. |
What are characteristics of Inheritance? |
|
- Abstract classes cannot be inherited.
- Sealed classes cannot be inherited.
- A derived class extends its direct base class.
- It can add new members to the derived class.
- Constructors and destructors are not inherited.
- A derived class can hide an inherited member.
- A derived class can override an inherited member.
|
|
|
123456789101112
Page 9 of 12