MockExams

OOP Paradigm vs POP, Encapsulation, Abstraction & Dynamic Binding

AI draft, not yet reviewedUnit 1: Introduction to Object-Oriented ProgrammingAbout 2 minutes

Idea in plain words

Procedure-Oriented Programming (POP) focuses on algorithms and functions moving data globally; Object-Oriented Programming (OOP) binds data and operations into self-contained objects.

Exam tip

High-yield exam topic (High).

Explanation

OOP overcomes the structural fragility of procedural software engineering where global state mutability often causes unintended side effects across large systems. In OOP, objects communicate exclusively via message passing (member function invocations), ensuring modular boundary encapsulation, testability, and enterprise maintainability.

Key points

  • Encapsulation: Bundling data and functions into a single unit (class) while restricting direct external access (data hiding via private specifiers).
  • Abstraction: Representing essential features of an entity without including background implementation details.
  • Inheritance: Mechanism where a new derived class acquires properties and behaviors of an existing base class, promoting software reusability.
  • Polymorphism: Ability of an entity (function or operator) to take multiple forms (Compile-time via overloading; Run-time via virtual functions).
  • Dynamic Binding: Code associated with a given procedure call is determined dynamically at runtime based on the target object's type.

Example

Example

A Car object abstracts complex internal internal-combustion physics behind a simple driver interface: steer(), accelerate(), and brake(). The internal fuel injection mapping is completely encapsulated.

Code examples

// C++ Class Demonstrating Encapsulation & Data Hiding
#include <iostream>
#include <string>
using namespace std;

class BankAccount {
private:
    string accountNumber; // Hidden data
    double balance;

public:
    BankAccount(string acc, double initBal) : accountNumber(acc), balance(initBal) {}

    void deposit(double amount) {
        if (amount > 0) balance += amount;
    }

    bool withdraw(double amount) {
        if (amount > 0 && amount <= balance) {
            balance -= amount;
            return true;
        }
        return false;
    }

    double getBalance() const { return balance; } // Controlled abstraction
};

Exam questions

  • [8 Marks] Compare Procedure-Oriented Programming (POP) with Object-Oriented Programming (OOP). Explain the core features of OOP.
  • [7 Marks] Explain the concept of data abstraction and encapsulation with an illustrative C++ class design.

BIT154CO

Switch Course

On this page

Past Exam Questions

Not asked in past exams yet

This topic hasn't appeared in previous exam papers.

Search BIT154CO

Reading

Theme
Reading mode
Text size
Default
Font
Line width
Line spacing