Inheritance is the property that allows the reuse of an existing class to build a new class. The principle in this sort of division is that each subclass shares common properties with the class from which it is derived. For example, all vehicle in a class may share similar properties of having wheels and a motor.
The idea of classes directly points towards the idea of inheritance. The concept of classes being divided into sub-classes can be related to the activities of our daily life. We know that the class of animals can be divided into mammals, amphibians, insects, reptiles etc. A class of vehicle is divided into cars, buses and motorcycles. Inheritance is a way to form new classes. The new derived classes, inherit attributes and behavior of the previous classes, which are known as base classes. Inheritance allows different data types to share the same code, leading to reduction in code size and an increase in functionality. Objects and classes extend the concept of abstract data types by adding the notation of inheritance. Such classes inherit their behavior from the parent classes or base class. There are four different types of inheritance and they are:
- Single Inheritance
- Multi Inheritance
- Hierarchical Inheritance
- Multiple Inheritance
Encapsulation is the process that allows selective hiding data and functions in a class. All communication to an object is done via message. A message is sent to the receiver. Message define the interface to an object. Providing access to an object only through its message, while keeping the details private is called information hiding. An equivalent buzzword is encapsulation.
Encapsulation is the wrapping up of data and associated functions in a single unit in such a way so that, only essential details are exposed and rest remain hidden. Encapsulation groups all the pieces of an object into a neat package. It avoids undesired side effects of the member data when it is define out of the class and also protects the intentional misuse of important data. Encapsulation ensures that only authorized functions access the relevant data thereby maintaining against unauthorized access to ensure data safety.
Polymorphism enables the same function to behave differently according to various classes. Object oriented languages (OOL) try to make existing code easily modifiable. Polymorphism means, the same functions may act differently on various classes.
It is an important feature of OOPS. The word polymorphism is derived from the Latin word “poly” means many and “morph” means form. Polymorphism is the concept that supports the capability of an object off a class to behave differently in response to a message or action. It is a property by which the same message can be sent to objects of several different classes, and each object can respond in a different way depending on its class. It is a major feature that allows the programmer to extend the language with new data types and operations. Polymorphism expresses how to carry out different processing steps using the same function name and ability of a single operator to perform more than one.
Data abstraction is the process of identifying properties and methods related to a particular entity as relevant to the application. Thus it is the process of examining all the available information about an entity to identify information about an entity to identify information that is relevant to the application. By grouping objects into classes, we are in fact performing data abstraction of a problem. Similar definitions are stored only once per class rather than once per instance of class. Methods can be written once for a class, so that the objects in a class benefit from code reuse.
It is a collection of data and methods. It denotes the act of re-presenting the essential features without including the explanations. An abstract data type is programmer defined data type that can be manipulated like system defined types. For example, in a switch board, you only press certain switches according to your requirement. What is happening inside, how it is happening, you needn’t know. This is abstraction.
Thank You for visiting us.
Visit again for daily updates and more tech related information.
You May Also Like: