What is a base class and derived class?
The concept of Base Class & Derived Class comes with a great advantage added to the programming world where the efficiency of the program is been increased due to its reusability factor.
Well, let us go ahead with the explanation of the following two terms...
What is a Base Class?
A base class is been one of the crucial parts of Object Oriented Programming language, which is used for the derivation of the other classes. It allows the creation of the classes which can reuse and implicitly inherit properties of the base class except for the constructors & Destructors.
A programmer can also extend the functionality of the base class, by overriding members and add up which would be relevant for the derived class.
A base class can be synonymized as superclass and parent class also.
A derived class inherits both behavior and data from the base class. Let us consider an example, “Engineering” can be a base class of which “Computer Science”,”Mechanical”,”Electrical”,”Electronics” and “Information Technology” are its derived classes. Well, these branch belongs to the sector named as engineering, but each one of them owns its specialization of its base class.
Properties owned by the base class are:
• Instantiation of the base class is automatically done before the derived classes
• Derived class can communicate with the base class at the time of instantiation by calling of the matching parameters or the base class constructors
• In a base class if abstract method is been defined then they are termed as abstract class and all the derived class or the non-abstract class need to override those methods
• “Abstract” keyword must be used to create an abstract base class during its declaration. Hence, it prevents initiation directly during the use of the ‘new’ keyword
What are derived class?
Derived Class are the one, formed using struct or class-key as its keyword, which is been derived using one or more base classes, which might be derived from other base classes, hence it forms an inheritance hierarchy.
The syntax for them are:
Public class A
public int b;
public void c
Class D extends A
Public int e;
Public void c()
These subtle examples really explain well to add few million more wiring to the neurons that persist…A small diagram to make it concrete...
All The Best!