Object | Class | Polymorphism | Encapsulation

C programs Programming


Object-oriented refers to a programming language, system or software methodology that is built on the concepts of logical objects. It also works through the creation, utilization, and manipulation of reusable objects to perform a specific task, process or objective. Object | Class | Polymorphism | Encapsulation | Data Abstraction.

Object | Class | Polymorphism | Encapsulation

1. Class

A class represents a group of objects that share common properties, behavior, and relationships. In other words, a class is an identifier that is a general name defined to represent objects of similar characteristics. For example, there are many mobiles in this world.

They are manufactured by different companies with different models. Though they have different models, capacities, and looks, they all have mostly the same functions as making calls, memory cards, cameras, etc. So, keeping these basic similar functions to the look, they are given a common name which is called a class. In the above case, the class name ‘Mobile’ is using.

2. Object

An object is an identifiable entity with some characteristics and behavior. An object is an instance of a class. Creating an object is like creating a variable of a data type. Once a class is declared, we can create variables of that type by using the class name. An object cannot exist without creating an instance of a class.

It is also possible to have multiple objects within a class. In reference to the above example of class Mobile, its object can give as Nokia, Samsung, Redmi, etc.

3. Inheritance

Inheritance is the ability to create a new class from an existing class with new data and methods. The existing class is called base class and the newly created classes are called the derived class. Thus, inheritance supports program reusability and reliability. For example: If we have a class Vehicle and the objects can be a car, bus, and truck.

Each of them has common characteristics like capacity, apply brakes, consume fuels, etc. Writing these similar characteristics in all 3 classes makes the program lengthy. To avoid this a base class having those similar characteristics is creating. And later on derived classes car, bus, a truck has created just by using this base class. Later, features other than in base class can also add to each derived class if needed.

4. Polymorphism

‘Poly’ means many and ‘morphe’ means form. Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different situations. The behavior depends on the data types used in the operation. The OOP supports polymorphism through function overloading, operator overloading, function overriding and template.

Example: Suppose let’s assume a class person. The same person can be a passenger on the bus, a student in school, the customer in a shop, etc. This state of having different forms according to places, situations is polymorphism.

To understand more about the Object-Oriented Concepts Visit.

5. Encapsulation

Encapsulation is an ability to bind functions and data together in a place and hide the data from unauthorized use from other parts of the program. Thus, function and data in OOP are always together within an object that provides data hiding, also known as encapsulation. Thus, data is hiding within an object.

6. Data Abstraction

Abstraction refers to an act of representing essential features without including background details or explanations. Thus, data abstraction is a methodology that supports the use of compound or complex objects without detailed knowledge.

Example: A car has different components like engine, steering, etc. So while creating a class Car, we need not know the internal functioning of those engines, steering of a car. We also can show only the external features in a class to the outside world. This also helps in hiding the implementation details of the car which is essential to do.

To know more about the programming and other world tech news Visit our Site Techolation.com

Written By: Santosh Banstola

B.E Computer, WRC, Nepal

Leave a Reply

Your email address will not be published. Required fields are marked *