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

Object Oriented Programming AssWPS Office

Object-Oriented Programming (OOP) is a paradigm that organizes data and behavior into objects based on classes, enhancing code management, reuse, and scalability. Its core principles include encapsulation, abstraction, inheritance, and polymorphism, which promote modularity and maintainability. OOP allows for dynamic binding and message passing between objects, making it suitable for complex applications.

Uploaded by

Carl Ghogeh
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 AssWPS Office

Object-Oriented Programming (OOP) is a paradigm that organizes data and behavior into objects based on classes, enhancing code management, reuse, and scalability. Its core principles include encapsulation, abstraction, inheritance, and polymorphism, which promote modularity and maintainability. OOP allows for dynamic binding and message passing between objects, making it suitable for complex applications.

Uploaded by

Carl Ghogeh
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 (OOP)

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.

Abstraction: Exposing only essential features and hiding implementation details.

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.

6. Basic Concepts of OOP

The four pillars of OOP are:

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.

Class and Object:


A class is a blueprint for creating objects and acts as the core unit of encapsulation in object-oriented
programming. It defines the data and functions, but this code only becomes active when an object (an
instance of the class) is created. Multiple objects can be created from a single class, each containing
similar data and using the functions defined in the class. For example, a "Car" class can have properties
like "model" and "year," with actions like "accelerate" or "brake." Objects are the runtime entities in C++
and can represent real-world entities like cars, people, or animals. Objects also occupy memory and
communicate by passing messages to each other.

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

Modularity: Programs are divided into separate classes or modules.

Reusability: Classes and methods can be reused in different parts of the program.

Scalability: Supports easy addition of new features without affecting existing code.

Maintainability: Simplifies debugging and updating code.

Others are;

1.Programs are divided into classes and functions.

2.Data is hidden and cannot be accessed by external functions.

3.Use of inheritance provides reusability of code.

4.New functions and data items can be added easily.

5.Data is given more important than functions.

6.Follows bottomup approach.

7.Data and function are tied together in a single unit known as class.

8.Objects communicate each other by sending messages in the form of function.


OOP makes complex applications easier to manage by creating a structured program where each part
interacts cohesively.

You might also like