UNIT-5_-Object-Oriented-Programming
UNIT-5_-Object-Oriented-Programming
Programming Paradigm
Definition:
A programming paradigm is a set of rules or methods that guide how programmers write
and organize code. It determines the approach to problem-solving and program
structure. The main paradigms include procedural, structural, and object-oriented
programming. Each paradigm has its own characteristics and is suited to specific kinds
of problems.
Definition:
1. Class
2. Object
3. Abstraction
● hides the complex internal details of an object and provides only the
Abstraction
essential information to the user.
● Users interact with a simplified interface without needing to understand how it
works internally.
● Example:
○ A car's steering wheel lets the driver control the direction without knowing
how the steering mechanism works.
4. Encapsulation
● Combines data (attributes) and functions (behaviors) into a single unit (class).
● Protects the internal state of an object by restricting access to its data through
public methods.
● Prevents unrelated functions from accessing or modifying private data.
● Example:
○ In a BankAccount class, attributes like balance are private, and
functions like deposit() and withdraw() control access to the
balance.
5. Inheritance
Object Instance of a class with specific A car object with color: red
attributes and behaviors. and behavior move().
Abstraction Hides complex details, showing A car's steering wheel lets you
only essential functionality. steer without knowing the
internal mechanism.
Data Security Less secure due to high More secure due to data hiding
possibility of data alteration. and controlled access
mechanisms.
Advantages of OOP:
Disadvantages of OOP:
Applications of OOP:
1. Software Development
2. Graphical User Interface (GUI) Development
3. Database Systems
4. Simulation and Modeling
5. Embedded Systems
6. Artificial Intelligence (AI) and Machine Learning
7. Financial Systems
8. Robotics
1. Software Development
GUIs are often designed using OOP because of their interactive nature and need for
event-driven programming.
● Example: Java Swing, JavaFX, and Tkinter for GUI design in desktop
applications.
● Benefit: Each component of the GUI (buttons, text fields, sliders) can be
represented as an object, making it easier to manage their behavior and
appearance.
3. Database Systems
Simulating real-world systems is a key area where OOP excels. It allows for the
modeling of complex entities with attributes and behaviors.
5. Embedded Systems
OOP is used in developing software for embedded systems, where software interacts
directly with hardware.
OOP is used in developing AI and machine learning systems because of its ability to
handle large datasets and modularize complex algorithms.
7. Financial Systems
OOP is used in banking and financial systems to manage transactions, accounts, and
customer data.
8. Robotics
OOP is crucial in robotics programming, where robots are modeled as objects with
various components and behaviors.