Skip to main content

Characteristics and advantages of OOP

Short answer

OOP characteristics: objects, classes, encapsulation, abstraction, inheritance, polymorphism, dynamic binding, message passing. Main advantages: reusability, modularity, easy maintenance.

What are the characteristics of Object Oriented Programming? What are the main advantage of OOP?

Object-Oriented Programming (OOP) is a programming approach in which a program is organised as a set of objects that combine data (attributes) and the operations (methods) on that data, and that work together by sending messages to each other. Languages such as C++, Java, Python and C# support OOP.

Characteristics of OOP

  1. Objects – an object is a run-time entity that has a state (attribute values), behaviour (methods) and a unique identity. Example: a particular bank account with number 1001 and balance Rs. 5000.

  2. Classes – a class is a template or blueprint from which objects are created. It defines the attributes and methods that all its objects share. Example: class Account.

  3. Encapsulation – data and the methods that act on it are bundled together in a class, and the internal data is hidden (private). Other objects can access it only through public methods. This is also called information hiding.

  4. Abstraction – only the essential features are shown to the user and the implementation details are hidden. A user calls withdraw() without knowing how the balance is stored.

  5. Inheritance – a new class (subclass) can be derived from an existing class (superclass) and reuse its attributes and methods, adding or overriding some of them. It forms an "is-a" hierarchy. Example: SavingsAccount is an Account.

  6. Polymorphism – one name can have many forms. The same message can produce different behaviour depending on the object that receives it.

    • Compile-time: function and operator overloading.
    • Run-time: method overriding through virtual functions.
  7. Dynamic binding – the method to be executed for a call is decided at run time, based on the actual type of the object. This makes run-time polymorphism possible.

  8. Message passing – objects communicate by calling each other's methods (sending messages), e.g. acc.deposit(500).

          +----------------------+
          |       Account        |
          |----------------------|
          | - accNo              |
          | - balance            |
          |----------------------|
          | + deposit(amt)       |
          | + withdraw(amt)      |
          | + calcInterest()     |
          +----------------------+
                    ^
          +---------+----------+
          |                    |
+------------------+  +------------------+
| SavingsAccount   |  | CurrentAccount   |
|------------------|  |------------------|
| + calcInterest() |  | + calcInterest() |
+------------------+  +------------------+

Small Java example:

class Account {
    private double balance;            // encapsulation
    public void deposit(double a) { balance += a; }
    public double calcInterest() { return 0; }
}
class SavingsAccount extends Account { // inheritance
    public double calcInterest() {     // polymorphism
        return 0.05 * 1000;
    }
}
Account a = new SavingsAccount();      // dynamic binding
a.calcInterest();                      // calls SavingsAccount version

Advantages of OOP

  1. Reusability – classes, once written and tested, can be reused in other programs, and inheritance lets new classes reuse existing code.
  2. Modularity – each class is a self-contained unit, so a large program is split into manageable parts that can be developed and tested separately.
  3. Easy maintenance – because data is encapsulated, a change inside a class does not affect the rest of the program as long as its interface stays the same.
  4. Data security – information hiding prevents other parts of the program from changing data accidentally.
  5. Extensibility – new features are added by creating new subclasses without changing existing, tested code (open-closed principle).
  6. Real-world modelling – objects map naturally to real things (student, book, account), so the design is easier to understand and to discuss with users.
  7. Smooth transition from analysis to code – the same object concepts are used in object-oriented analysis (OOA), design (OOD) and programming, so models map directly to code.
  8. Parallel development and scalability – different teams can work on different classes, which suits large, complex systems.
  9. Flexibility through polymorphism – code written for a superclass works for any subclass, reducing if-else/switch code.

Main drawbacks, for balance: programs can be larger and slightly slower, and good class design needs experience.

✓ Answer checked by Claude Sonnet 5.5

All Software Engineering chapter 2 questions →