Allows the defining of a child class that reuses or inherits the behavior of a parent class (or existing class).
The inheriting class is called a derived class or subclass
The existing class whose members are being inherited is called base class or superclass.
Subclass can only inherit from a single superclass.
The colon (:) symbol indicates that the class DerivedClass inherits the members of the class BaseClass.
protected members of a base class are inherited and are accessible by their derived classes.
The keyword protected is used to declare a protected member.
base keyword is used to specify which constructor from the base class should invoke when creating instances of the derived class.
Declaring a method in a derived class with the same name as the method from its base class is called method overriding.
Method overriding is redefining the functionality of an existing method.
The overridden method from the base class should be declared as virtual
The virtual modifier specifies that a derived class can override the method in the base class.
The override modifier is required to modify the abstract or virtual implementation of the inherited method and must have the same method signature as the overridden method (virtual method).
Only an abstract and virtual method can be overridden in C#.
Abstract class is a base class that cannot be instantiated to create an object.
The abstract keyword is used to declare an abstract class and is placed before the class name.
Polymorphism, which means “multiple forms,” is one of the fundamental concepts of object-oriented programming.
POLYMORPHISM enables classes to provide multiple methods with the same name but with different implementations or behavior.
Compile time polymorphism – Also known as “static polymorphism,”
Compile time polymorphism is implemented using method overloading. In method overloading, a method is executed depending on the number and type of parameters passed to it.
Runtime polymorphism – This polymorphism is a process in which the compiler determines which method to call during runtime.
Runtime process is also called dynamic polymorphism or late binding. This is achieved using method overriding.
An interface only contains the signatures of methods, properties, and events as its members.
Interfaces are not classes. In C#, interfaces are defined using the interface keyword.
A property can access a private data member of the class.
An interface cannot contain instance variables or fields but may contain properties.