2.
Object-Oriented Programming:
Object-Oriented Programming System (OOPs) is a programming paradigm based
on the concept of objects that contain data and methods, instead of just functions and
procedures.
The object oriented programming approach is developed in order to remove some of
the flaws of procedural programming.
The primary purpose of object-oriented programming is to increase the flexibility
security and maintainability of programs.
Object oriented programming brings together data and its behavior (methods) into a
single entity (object) which makes it easier to understand how a program works.
Advantages of Object Oriented Programming
1. It emphasis on data rather than procedure.
2. It is based on the principles of inheritance, polymorphism, encapsulation and data
abstraction.
3. Programs are divided into objects.
4. Data and the functions are wrapped into a single unit called class so that data is
hidden and is safe from accidental alternation.
5. Objects communicate with each other through functions.
6. New data and functions can be easily added whenever necessary.
7. Support bottom-up approach in program design.
Difference between POP and OOP:
Aspect OOP POP
Core Concept Focus on objects and classes. Focus on functions and procedures.
Code Organization Organized around classes and objects. Organized around functions and
procedures.
Data Accessibility Emphasizes encapsulation, data is accessed Data may be global and accessible
through methods. to all functions.
Code Reusability Promotes code reusability through inheritance and Functions can be reused to certain
polymorphism. extend.
Inheritance Supports inheritance for code sharing and Does not have inheritance support
extending functionality.
Polymorphism Allows polymorphic behavior, where methods can Does not have polymorphic support
behave differently based on the object's type.
Modularity Encourages modularity through classes and Modularity can be achieved through
objects, promoting easy maintenance and updates. functions, but not as naturally as in
OOP.
Data Hiding OOP provides Data Hiding so POP does not have any
provides more security. proper way for hiding data so it
is less secure