Object Oriented Programming AssWPS Office
Object Oriented Programming AssWPS Office
OOP is a paradigm that organizes data and behavior into objects, which are instances of classes
(blueprints for objects). The core idea is to combine data and methods that operate on data into single
entities (objects), making it easier to manage, reuse, and scale code.
Core Principles:
Encapsulation: Wrapping data and functions into a single unit, hiding internal states and protecting data.
Inheritance: Creating new classes based on existing ones, enabling code reuse.
Polymorphism: Allowing different objects to be treated as instances of the same class, even if they
behave differently.
OOP addresses the limitations of structured and procedural programming by creating a modular and
maintainable structure.
Encapsulation: Combines data and methods in a single class, protecting data from unintended
modification.
Abstraction: Simplifies complex systems by focusing only on essential properties, hiding unnecessary
details.
Inheritance: Allows a new class (subclass) to inherit attributes and methods from an existing class
(superclass), promoting code reuse.
Polymorphism: Enables one interface to control access to a general class of actions, allowing for
dynamic method binding.
These principles make OOP modular, reusable, and easier to manage for larger applications.
Data Hiding: Data hiding hides the data from external access by the user. In OOP language we have
special keywords like private, protected etc., which hides the data.
Example: "Animal" can be a class, while "Lion," "Tiger," and "Elephant" are its objects.
Dynamic Binding:
Binding refers to linking a function call to its definition.Static Binding occurs at compile-time.Dynamic
Binding happens at runtime, where the specific function called depends on the program’s execution.
Message Passing:
Objects communicate with each other in C++ by passing messages. A message consists of the method
name and parameters (e.g., object.method(parameters)). This message passing is essentially a method
call, where an object calls a function with specific arguments.
7. Characteristics of OOP
Reusability: Classes and methods can be reused in different parts of the program.
Scalability: Supports easy addition of new features without affecting existing code.
Others are;
7.Data and function are tied together in a single unit known as class.