Object oriented programming
Object oriented programming
Class Objects
Fruits
Apple
Banana
Mango
Oranges
Class
A class is a group of objects have common properties it is a template or
blueprint from which objects are created.
- Its not non primitive data type
- It can’t be physical (no memory space)
Object
Objects are basic buildings blocks for designing programs
An object is a collection of data members and associated members functions
An object may represent a person, place or a table of data
Each object is identified by a unique name, each object must be a member of a
particular class.
Example: Apple, orange, mango are the objects of class fruits
Object-Cars
Car data
Name
Model NO.
Model functions
The engine
Braking system
{https://www.naukri.com/code360/library/what-is-an-object-in-object-
oriented-programming-oops}
Benefits of Using Objects in Programming
1. Encapsulation
Encapsulation is one of the main advantages of using objects. The process of
concealing an object's implementation details from the public is known as
encapsulation. This can help to simplify and make the code easier to understand
by keeping an object's core operations hidden from other software components.
Because an object's methods are the sole way to change its internal state,
encapsulation also gives you more control over how the object behaves.
2. Modularity
Additionally, objects can enhance a program's modularity. A software is said to
be modular if it is divided into smaller, easier-to-manage components. These
smaller components, each of which represents a distinct facet of the program's
functioning, can be represented as objects. Because modifications to one item
won't impact other program objects, this can facilitate program development
and maintenance.
3. Polymorphism
Another advantage of utilizing objects is polymorphism. The ability of an item to
change its form is known as polymorphism. This implies that without changing
the object itself, things can be employed in a variety of contexts. Depending on
the context, a "vehicle" object could, for instance, stand in for a car, truck, or
motorcycle.
4. Inheritance
The process by which one class acquires the traits and capabilities of another is
known as inheritance. Reusability of programming is the primary purpose of
inheritance. Only the features of each subclass need to be specified. The parent
class is a direct source of the remaining characteristics.