0% found this document useful (0 votes)
2 views

Object oriented programming

Object-oriented programming (OOP) is a methodology that utilizes self-contained objects containing methods and data that interact with each other. Classes serve as templates for creating objects, which inherit properties and methods from their respective classes. Key benefits of OOP include encapsulation, modularity, polymorphism, and inheritance, which enhance code organization and reusability.

Uploaded by

jimmycartel0625
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Object oriented programming

Object-oriented programming (OOP) is a methodology that utilizes self-contained objects containing methods and data that interact with each other. Classes serve as templates for creating objects, which inherit properties and methods from their respective classes. Key benefits of OOP include encapsulation, modularity, polymorphism, and inheritance, which enhance code organization and reusability.

Uploaded by

jimmycartel0625
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Object oriented programming

Object-oriented programming (OOP) – a programming methodology that uses


self-contained objects, which contain programming statements (methods) and
data, and which communicate with each other.
{AS and A Level Computer Science by Hodder - Copy.pdf}

What are Classes and Objects?


{https://www.w3schools.com/java/java_oop.asp }
{https://www.slideshare.net/slideshow/object-oriented-programming-
129281522/129281522#2}
{https://www.slideshare.net/slideshow/basic-concept-of-oops/142211372}
Classes in OOP:
Classes and objects are the two main aspects of object-oriented programming.

Class Objects
Fruits
Apple
Banana
Mango
Oranges

So a class is a template for objects, and an object is an instance of a class.


When the individual objects are created, they inherit all the variables and
methods from the class.
Everything in Java is associated with classes and objects, along with its attributes
and methods. For example: in real life, a car is an object. The car has attributes,
such as weight and color, and methods, such as drive and brake.
A Class is like an object constructor, or a "blueprint" for creating objects.

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.

You might also like