Object
While class denotes that model or prototype, an object is the actual player of a class, that is, an object is an instance of a class. Precisely, objects are variables of a user-defined data type class. The variables of a class contain the data and the functions perform specific operations based on the objects contained in a class.
Inheritance
Often, solving complex programming problems requires you to build classes that possess certain common characteristics or behaviors.
Thus, to avoid repetition you need to gather all the common characteristics within a single class known as the ‘parent class.’ Now, all the classes having similar features can ‘inherit’ the common traits from the parent class. This is called ‘Inheritance.’
Apart from inherited features from the parent class, the new classes can have their distinct fields and methods.
There also exists the concept of ‘multiple inheritances’ wherein some object-oriented programming languages support the inheritance of specific features from multiple classes.
Abstraction
Abstraction refers to the process of eliminating complexity by hiding the unnecessary details of the implementation from the user. This allows the user to apply a more complex logic on top of the given abstraction without even being aware of the underlying or hidden complexity.
Encapsulation
Encapsulation refers to the process of bundling methods and data that function on the data contained within a single unit such as a class. There are two aspects of encapsulation – one is the restrict access to particular fields and methods of a class and the second is the merge similar data and methods.
It is often used to hide the internal representation of an object from the user which is known as ‘information hiding.’
Interface
An interface is a programming protocol for two unrelated classes to communicate with one another. An alternative to inheritance, an interface that defines the actions of objects.
An interface is placed within its distinct file bearing the same name as the interface (in Capital) and ends with the familiar language extension, for instance, “.as”. The primary purpose of interfaces is to enable the computer to know what kind of properties a particular object should have and to enforce those properties on the object.
Association
An association denotes any type of relationship between two objects. Precisely, it refers to the multiple associations between objects such as one-to-one, one-to-many, many-to-one, and many-to-many. The objects may be instances of unrelated classes and they collaborate to accomplish their unique goals without manipulating the lifecycle of the other.
Aggregation
Aggregation is nothing but a special type of association. It is a relationship where one object belongs to another object but despite that, they are both independent objects. It is also known as a “has-a” relationship.
Composition
A composition is a relationship between two objects where one object is under complete control of the other, and hence, has no independent lifecycle. While it is similar to aggregation as in one object contains another object, unlike aggregation, the object contained cannot exist without the container object.
Polymorphism
In general terms ‘polymorphism’ refers to the ability to exist in multiple forms. However, in OOPS, the term polymorphism refers to the ability of a programming language to process objects differently in accordance with their data type or class.
Thus, polymorphism is essentially a language’s ability to ‘redefine’ the methods for different derived classes.
While this is just a nudge to steer you in the right direction, there are many other concepts that you must learn to master OOPS. For now, starting with the basics would be a wise way to go.
Read about, Characteristics of OOPS
Frequently Asked Questions
Why are OOPs used?
OOPs is a programming concept which lets you break down your problem in smaller sections and helps to make your code readable and efficient.
What are the 4 basics of OOP?
OOPs functions on four pillars – encapsulation, abstraction, inheritance and polymorphism.
What are OOPs in C++?
OOPs in C++ is the utilisation of the 4 basics of object oriented programming with the help of classes and objects.
What is OOP in simple words?
In simple words, OOP means that there exists a combination of data and functions which represent real world entities.
What is an OOP example?
Assume that you have a class student which comprises various attributes like student name, enrollment number, courses enrolled and CGPA. Every instance (object) of this class will represent different students and each student will have all attributes and methods which are declared in the class.
What is the full form of OOPs?
The full form of OOPS is Object Oriented Programming Systems.