Object Oriented Programming
Object-Oriented Programming (OOP) is a programming
paradigm that focuses on creating objects that contain both
data (properties) and code (methods) that work together to
solve complex problems. It provides a structured and
modular approach to software development.
By Group 8
Bikrant Lekhak
Bidith Aryal
Binamra Bhandari
Binayak Chaudhary
Binod Chapagain
What is an Object?
Real-World Entity Data and Behavior
An object is a real-world An object encapsulates
entity that has both data (properties)
properties (attributes) and the functions
and can perform actions (methods) that operate
(methods). on that data.
Unique Identity
Each object has a unique identity, allowing it to be
distinguished from other objects.
What is a Class?
Blueprint Object Creation Encapsulation
A class is a blueprint or From a class, you can create Classes provide a way to
template that defines the multiple objects, each with their encapsulate data and methods,
properties and methods own unique data but sharing hiding the implementation
common to all objects of that the same structure and details and exposing only the
class. behavior. necessary functionality.
Encapsulation: Hiding
Implementation Details
1 Data Hiding
Encapsulation involves hiding the internal details of an
object from the outside world, exposing only the
necessary interface.
2 Abstraction
By encapsulating data and methods, objects can
provide a simplified, abstract view of their functionality.
3 Modularity
Encapsulation promotes modularity, allowing changes
to the internal implementation without affecting the
rest of the system.
Polymorphism: One
Interface, Multiple
Implementations
1 Flexibility 2 Dynamic Dispatch
Polymorphism allows The appropriate
objects of different method
classes to be used implementation is
interchangeably, as determined at runtime
long as they share a based on the actual
common interface. object type, not the
declared type.
3 Code Reuse
Polymorphism enables code reuse, as common
interfaces can be shared across different
implementations.
Abstraction: Focusing on Essential
Features
Simplification
Abstraction involves simplifying complex systems by focusing on the essential
features and hiding unnecessary details.
Clarity
By abstracting away complexity, objects can provide a clear and understandable
interface for developers to work with.
Flexibility
Abstraction allows for greater flexibility, as the underlying implementation can be
changed without affecting the external interface.
Inheritance: Reusing Code and Extending Functionality
Code Reuse
Inheritance allows classes to inherit properties and methods from parent classes, promoting code reuse and reducing duplication.
Specialization
Subclasses can extend and specialize the functionality of their parent classes, creating a hierarchical relationship.
Polymorphism
Inheritance enables polymorphism, where objects of a subclass can be used in place of their parent class.
Real-world examples of OOP
Cars Each car is an object with
properties (color, make,
model) and methods (start,
accelerate, brake).
Computers A computer is an object
composed of various
hardware components (CPU,
RAM, storage) and software
(operating system,
applications).
Smartphones A smartphone is an object
with features like a camera,
GPS, and various apps, all
working together to provide
a seamless user experience.