VOOZH about

URL: https://www.geeksforgeeks.org/dsa/introduction-of-object-oriented-programming/

⇱ Introduction of Object Oriented Programming - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Introduction of Object Oriented Programming

Last Updated : 11 Jun, 2026

Object-Oriented Programming (OOP) is a programming paradigm that organizes software around objects rather than functions and logic. An object contains both data (attributes) and methods (behavior), making programs more modular and reusable. OOP helps developers build scalable, maintainable, and real-world applications efficiently.

  • Improves code reusability
  • OOP is based on the concept of objects and classes
  • Makes programs easier to understand and manage

Concepts of Object-Oriented Programming (OOP)

The diagram below demonstrates the Java OOPs Concepts

👁 object_oriented_programming
OOP

Class

A class is a blueprint or template used to create objects. It defines the properties (data) and behaviors (methods) that objects will have.

  • Contains data members and methods.
  • Does not occupy memory until an object is created.

Example: A Car represents a class (blueprint), while BMW, Mercedes, and Audi represent objects (instances) created from that class.

👁 Class
Class

Object

An object is an instance of a class. It represents a real-world entity and can access the properties and methods defined in the class.

  • Occupies memory when created.
  • Used to access class members.

Example: Dog is a class, Tommy is an object of that class.

👁 object
Object

Encapsulation

Encapsulation is the process of binding data and methods together into a single unit and restricting direct access to data using access modifiers.

  • Improves security.
  • Accesses data through getter and setter methods.
👁 Encapsulation
Encapsulation

Abstraction

Abstraction hides implementation details and shows only the essential features of an object.

  • Improves code simplicity.
  • Achieved using abstract classes and interfaces.

Example: An ATM or a coffee machine represents abstraction, where the user interacts with simple operations while the internal working and implementation details remain hidden.

👁 abstraction
Abstraction

Inheritance

Inheritance allows one class to acquire the properties and methods of another class.

  • Establishes parent-child relationship.
  • Supports method overriding.

Example: Dog, Cat, Cow can be Derived Class of Animal Base Class

👁 inheritance-660x454
Inheritance

Polymorphism

Polymorphism means "many forms" and allows the same method or interface to perform different actions depending on the object that invokes it. It improves flexibility and enables dynamic behavior in object-oriented applications.

  • Allows one interface, multiple implementations.
  • Achieved through method overloading and method overriding.

Example: Different animals represent polymorphism, where the same method speak() produces different outputs like Bark, Meow, and Moo depending on the object.

👁 Polymorphysm
Polymorphism

Advantages of OOP

  • Modularity: Programs are divided into independent classes, making development easier.
  • Easy Maintenance: Changes in one part of the program have minimal impact on others.
  • Improved Readability: Well-structured classes make code easier to understand.
  • Scalability: Applications can be expanded and enhanced without major modifications.
  • Faster Development: Reusable components and modular design speed up development.
  • Better Testing and Debugging: Individual classes can be tested and debugged independently.
  • Real-World Modeling: Objects represent real-world entities, making system design intuitive.

Limitations of OOP

While OOP provides many benefits, it also has some limitations:

  • Steeper Learning Curve: Concepts such as classes, objects, inheritance, polymorphism, abstraction, and encapsulation can be challenging for beginners.
  • Additional Overhead for Small Programs: OOP may introduce extra classes and structure that are unnecessary for simple applications.
  • Increased Design Complexity: Designing a proper class hierarchy and object relationships requires careful planning.
  • Higher Memory Consumption: Creating and managing a large number of objects can require more memory compared to procedural approaches.

Related Article

Comment
Article Tags:
Article Tags: