‘Poly’ means many, and ‘morphism’ means forms. Hence, Polymorphism represents “many forms,” which arises when several classes are connected by inheritance.
Polymorphism uses the same inheritance approaches to carry out various objectives and enables a single function in several ways.
Data Hiding: The user will be unaware of the class’s internal implementation, and the user will not be able to see how the class keeps values in variables. He knows that we are giving accessor values and that variables are initialized to that value.
Increased Flexibility: Depending on our needs, we may make the class’s variables read-only or write-only.
Reusability: Encapsulation promotes reusability and makes it simple to adapt to new requirements.
When a derived class inherits from a base class, it inherits all of the base class’s methods, fields, attributes, and events. For the behavior of virtual techniques, the creator of the derived class has many options:
Regardless of how many classes have been established between the virtual member and the class that first declared it, virtual members remain virtual.
A derived class that has replaced or overridden a method or property on the base class can still use the base keyword to access the method or property on the base class.
If you want a member in your derived class to have the same name as a member in a base class, use the new keyword to conceal the base class member.