Object Oriented Programming
Basic Introduction of OOP
Object Oriented Programming Paradigm (OOPP) is a programming approach that models software design based on real-world objects. It focuses on creating systems where objects interact with each other, similar to real-life scenarios.
Key Concepts:
- Real-world Representation: OOP models real-life entities (like student, car, bank account) as objects in a program.
- Objects and Interaction: Programs are designed as a group of interacting objects that communicate to perform tasks.
- Class: A class is a blueprint that defines properties (data) and behaviors (methods) of objects.
- Object: An object is an instance of a class that represents a real-world entity.
- Encapsulation: A class groups related data and functions together into a single unit.
- Packages: Large applications are divided into packages, which are collections of related classes
Structure of OOPP:
- Application → divided into packages
- Package → contains multiple classes
- Class → contains objects and their behaviors.
Advantages of OOPP:
- Easy to model real-world problems
- Improves code reusability
- Makes programs modular and organized
- Enhances maintainability and scalability
OOPP হলো একটি programming পদ্ধতি যেখানে real-life object ব্যবহার করে software তৈরি করা হয়। এখানে object গুলোর মধ্যে interaction হয়, যা মানুষের বাস্তব জীবনের মতো কাজ করে।
মূল ধারণা:
- Real-world Representation: বাস্তব জীবনের বস্তু (যেমন student, car, bank account) object হিসেবে ব্যবহৃত হয়।
- Objects Interaction: Program অনেকগুলো object-এর সমন্বয়ে তৈরি হয় যারা একে অপরের সাথে কাজ করে।
- Class: Class হলো একটি blueprint যা object-এর data ও behavior নির্ধারণ করে।
- Object: Object হলো class-এর instance যা বাস্তব entity নির্দেশ করে।
- Encapsulation: Data ও function একসাথে একটি unit হিসেবে রাখা হয়।
- Packages: বড় program-কে package-এ ভাগ করা হয়, যেখানে অনেক class থাকে।
Structure:
- Application → package-এ বিভক্ত
- Package → class-এর সমষ্টি
- Class → object তৈরি করে
সুবিধা:
- বাস্তব সমস্যার সহজ সমাধান
- Code reuse করা যায়
- Program organized থাকে
- Maintain ও expand করা সহজ
Python,
C++,
JAVA,
Visual C,
Visual Basic
- Modularity & Reusability: Programs are divided into small objects, making code reusable and easier to manage.
- Encapsulation: Data and methods are combined into one unit (class), hiding internal details and improving data security.
- Abstraction: Only important features are shown, reducing complexity and making programs easier to understand.
- Inheritance: New classes can reuse properties of existing classes, reducing code duplication.
- Polymorphism: Same function can behave differently for different objects, increasing flexibility.
- Flexibility & Scalability: OOP supports large and complex systems by organizing code into manageable units.
- Easy Maintenance: Changes can be made in one class without affecting the entire program.
- Team Development: Multiple developers can work on different classes simultaneously.
- Real-World Modeling: Programs can be designed based on real-life objects, making them intuitive.
- Modularity & Reusability: Program ছোট ছোট object-এ ভাগ করা যায়, যা পুনঃব্যবহারযোগ্য।
- Encapsulation: Data ও function একসাথে রাখা হয়, ফলে data নিরাপদ থাকে।
- Abstraction: শুধুমাত্র গুরুত্বপূর্ণ অংশ দেখানো হয়, ফলে complexity কমে।
- Inheritance: এক class থেকে অন্য class তৈরি করা যায়, ফলে code reuse হয়।
- Polymorphism: একই function বিভিন্নভাবে কাজ করতে পারে।
- Flexibility & Scalability: বড় program সহজে manage ও expand করা যায়।
- Easy Maintenance: একটি class পরিবর্তন করলে পুরো program পরিবর্তন করতে হয় না।
- Team Development: একাধিক programmer আলাদা class নিয়ে কাজ করতে পারে।
- Real-Life Modeling: বাস্তব জীবনের মতো object ব্যবহার করে program তৈরি করা যায়।
| Structure (Structured Programming) | OOP (Object-Oriented Programming) |
|---|---|
| Focuses on functions and procedures | Focuses on objects and classes |
| Data and functions are separate | Data and functions are combined (encapsulation) |
| No concept of inheritance | Supports inheritance |
| No polymorphism | Supports polymorphism |
| Less data security | Provides data hiding and security |
| Suitable for small programs | Suitable for large and complex programs |
| Example: C | Example: C++, Java |
| Structure Programming | OOP |
|---|---|
| Function ভিত্তিক | Object ও Class ভিত্তিক |
| Data ও function আলাদা | Data ও function একসাথে (encapsulation) |
| Inheritance নেই | Inheritance আছে |
| Polymorphism নেই | Polymorphism আছে |
| Data security কম | Data security বেশি |
| ছোট program-এর জন্য উপযুক্ত | বড় ও complex program-এর জন্য উপযুক্ত |
| উদাহরণ: C | উদাহরণ: C++, Java |
Properties of OOP
1. Class
A class is a user-defined data type that acts as a blueprint for creating objects. It contains:
- Data members (variables)
- Member functions (methods)
Example:
Car is a class → properties: wheels, speed, mileage.
All cars share these common features.
2. Object
An object is an instance of a class and represents real-world entities.
- Has identity (name)
- Has state (data)
- Has behavior (functions)
Example:
Dog → color, breed (state); bark, eat (behavior)
3. Abstraction
Abstraction means showing only essential features and hiding internal details.
Example:
Driving a car → You use accelerator/brake but don’t know internal mechanism.
4. Encapsulation
Encapsulation means wrapping data and methods into a single unit (class) and restricting direct access.
- Provides data security
- Also called data hiding
Example:
Bank system → You cannot directly access data, only through methods
5. Inheritance
Inheritance allows one class to acquire properties of another class.
- Promotes code reuse
- Reduces redundancy
Example:
Animal → Dog inherits properties like eat, sleep.
6. Polymorphism
Polymorphism means “many forms” — same function behaves differently.
- Compile-time: Method overloading
- Run-time: Method overriding
Example:
Person → father, employee, husband (same person, different roles)
1. Class
Class হলো একটি user-defined data type যা object তৈরির blueprint হিসেবে কাজ করে।
- Data (variable)
- Function (method)
Example:
Car → wheels, speed, mileage
2. Object
Object হলো class-এর instance যা বাস্তব জীবনের entity নির্দেশ করে।
- Identity (নাম)
- State (data)
- Behavior (function)
Example:
Dog → color, breed; bark, eat
3. Abstraction
Abstraction হলো শুধুমাত্র গুরুত্বপূর্ণ তথ্য দেখানো এবং ভিতরের কাজ লুকানো।
Example:
Car চালানো → ভিতরের engine কীভাবে কাজ করে জানা লাগে না
4. Encapsulation
Encapsulation হলো data ও function একসাথে রাখা এবং direct access বন্ধ রাখা।
- Data security দেয়
- Data hiding বলা হয়
Example:
Bank → সরাসরি data access করা যায় না
5. Inheritance
Inheritance হলো এক class থেকে অন্য class properties নেওয়া।
- Code reuse হয়
- Duplicate কমে
Example:
Animal → Dog inherit করে
6. Polymorphism
Polymorphism মানে “একাধিক রূপ” — একই function বিভিন্নভাবে কাজ করে।
- Compile-time → Overloading
- Run-time → Overriding
Example:
একজন মানুষ → father, employee, husband

Encapsulation is a fundamental concept of OOP where data (variables) and methods (functions) are combined into a single unit (class) and direct access to internal data is restricted.
Definition:
Encapsulation means wrapping data and functions together and hiding internal details from outside access.
Key Idea:
- Data is made private
- Access is provided through public methods
- Ensures data security and control
Example (Bank Account):
class BankAccount {
private:
double balance;
public:
void deposit(double amount) {
balance += amount;
}
void withdraw(double amount) {
if (balance >= amount)
balance -= amount;
}
double getBalance() {
return balance;
}
};
Explanation:
- balance is private → cannot be accessed directly
- Use deposit() and withdraw() to modify balance
- getBalance() returns value safely
Advantages:
- Provides data security
- Prevents unauthorized access
- Improves code maintainability
- Supports modular programming
Encapsulation helps in building secure, organized, and reliable programs by controlling access to data.
Encapsulation হলো এমন একটি প্রক্রিয়া যেখানে data এবং function একসাথে রাখা হয় এবং data-তে সরাসরি access সীমাবদ্ধ করা হয়।
সংজ্ঞা:
Data ও method একত্রে রাখা এবং internal data hide করা।
মূল ধারণা:
- Data private রাখা হয়
- Public method দিয়ে access করা হয়
- Data নিরাপদ থাকে
Example:
class BankAccount {
private:
double balance;
public:
void deposit(double amount) {
balance += amount;
}
void withdraw(double amount) {
if (balance >= amount)
balance -= amount;
}
double getBalance() {
return balance;
}
};
ব্যাখ্যা:
- balance সরাসরি access করা যায় না
- Method ব্যবহার করে modify করতে হয়
সুবিধা:
- Data নিরাপদ থাকে
- Unauthorized access বন্ধ করে
- Code maintain করা সহজ হয়
উপসংহার:
Encapsulation program-কে secure ও structured করে তোলে।
Advantages of Encapsulation:
Data Security: It hides internal details, preventing unauthorized access and misuse.
Easy Maintenance: Since data access is controlled, changes in the code don’t affect other parts.
Better Flexibility: Internal workings of a class can be modified without affecting how others interact with it.
Less Complexity: Users only need to know how to use the class, not its internal details.
Improved Debugging: Restricting access to data makes it easier to find and fix bugs.
Advantages of Inheritance:
Code Reusability: A new class can use the properties and methods of an existing class, reducing duplicate code.
Clear Structure: It helps in organizing code by creating a hierarchy of classes.
Easy Expansion: New functionality can be added to a class without modifying existing code.
Simplifies Management: Subclasses inherit properties from the parent class, making code more organized and efficient.
🎥 Video Solution: How encapsulation and inheritance are advantageous in OOP>
[urcr_restrict]
Data Abstraction is an important concept in OOP where only the essential information is shown and the implementation details are hidden.
Definition:
It means hiding internal complexity and showing only necessary features to the user.
Real-Life Example:
A person drives a car using accelerator and brake without knowing the internal engine mechanism.
Ways to Achieve Data Abstraction:
1. Using Header Files
Functions are used without knowing their internal working.
- Example: sort() function
- We know it sorts data but not how it works internally
2. Using Classes
Classes group data and functions and control access using access specifiers.
Abstraction using Access Specifiers:
- Public: Accessible from anywhere
- Private: Accessible only inside the class
- Protected: Accessible in derived (child) classes
Example:
class Example {
private:
int data;
public:
void setData(int x) {
data = x;
}
int getData() {
return data;
}
};Explanation:
- data is hidden (private)
- Access is controlled through setData() and getData()
Advantages:
- Reduces complexity
- Improves code readability
- Enhances security
- Supports modular programming
Data abstraction helps in designing simple, secure, and maintainable programs by hiding unnecessary details.
Data Abstraction হলো এমন একটি পদ্ধতি যেখানে প্রয়োজনীয় তথ্য দেখানো হয় এবং অপ্রয়োজনীয় detail লুকানো হয়।
সংজ্ঞা:
Internal কাজ লুকিয়ে রেখে শুধুমাত্র দরকারি অংশ দেখানো।
বাস্তব উদাহরণ:
গাড়ি চালাতে আমরা শুধু accelerator ও brake ব্যবহার করি, ভিতরের engine কিভাবে কাজ করে তা জানি না।
কিভাবে করা হয়:
1. Header File ব্যবহার করে
- Function ব্যবহার করি কিন্তু ভিতরের logic জানি না
- Example: sort()
2. Class ব্যবহার করে
- Data ও function একসাথে রাখা হয়
- Access control করা হয়
Access Specifier:
- Public: সব জায়গা থেকে access করা যায়
- Private: শুধু class-এর ভিতরে
- Protected: child class access করতে পারে
Example:
class Example {
private:
int data;
public:
void setData(int x) {
data = x;
}
int getData() {
return data;
}
};
ব্যাখ্যা:
- data hidden থাকে
- Method দিয়ে access করা হয়
সুবিধা:
- Complexity কমায়
- Code সহজ হয়
- Security বাড়ায়
Data abstraction program-কে simple ও secure করে তোলে।
[/urcr_restrict]
- Public
- Private
- Protected
class ClassName {
private:
// private members
public:
// public members
protected:
// protected members
};
Example:class Employee {
private:
int salary;
public:
int id;
string name;
string getName() {
return name;
}
protected:
void setSalary(int s) {
salary = s;
}
};
Explanation:- salary (private) → cannot be accessed directly outside class
- id, name (public) → accessible from anywhere
- setSalary() (protected) → accessible in derived classes
- Accessible from anywhere in the program
- Used for general data and functions
- Accessible only inside the class
- Used to hide sensitive data
- Accessible within class and derived classes
- Used in inheritance
- Provides data security
- Prevents unauthorized access
- Supports encapsulation
- Public
- Private
- Protected
class Employee {
private:
int salary;
public:
int id;
string name;
protected:
void setSalary(int s) {
salary = s;
}
};
ব্যাখ্যা:- salary → private (বাইরে থেকে access করা যায় না)
- id, name → public (সব জায়গা থেকে access করা যায়)
- setSalary → protected (child class ব্যবহার করতে পারে)
- সব জায়গা থেকে access করা যায়
- শুধু class-এর ভিতরে access করা যায়
- data নিরাপদ রাখে
- class ও child class-এ access করা যায়
- Data নিরাপত্তা দেয়
- Unauthorized access বন্ধ করে
- Encapsulation support করে
OOP Properties : Inheritance
Inheritance is a mechanism in OOP where a child class (derived class) acquires the properties (data and methods) of a parent class (base class). It promotes code reuse and reduces redundancy.
Example:
If class A has variable x and function print(), then class B can inherit them:
class A {
public:
int x = 10;
void print() {
cout<<"Hello"<<endl;
}
};
class B : public A {};
Now object of B can use:
B b; b.print(); cout<<b.x;
Inheritance হলো এমন একটি প্রক্রিয়া যেখানে একটি child class অন্য একটি parent class-এর properties (data ও function) গ্রহণ করে।
Example:
class A {
public:
int x = 10;
void print() {
cout<<"Hello"<<endl;
}
};
class B : public A {};
এখন B class-এর object দিয়ে A-এর property ব্যবহার করা যায়।
[urcr_restrict]
In Object-Oriented Programming, inheritance involves several important terms that describe relationships between classes.
- Super Class: A class whose properties are inherited by another class. It is also known as the parent or base class.
Example: class Animal is a superclass of class Dog. - Parent Class: The class that gives its properties (data and methods) to another class.
Example: Animal is the parent class of Dog. - Base Class: Another name for the parent class from which a class is derived.
Example: Animal is the base class. - Derived Class: A class that inherits properties from another class. It is also called a child or subclass.
Example: Dog is the derived class of Animal. - Child Class: The class that receives properties from the parent class.
Example: Dog is the child class. - Subclass: Another term for a derived or child class.
Example: Dog is a subclass of Animal.
Simple Example:
class Animal {}; // Super / Parent / Base class
class Dog : public Animal {}; // Derived / Child / Subclass
OOP-এ inheritance বোঝাতে কিছু গুরুত্বপূর্ণ টার্ম ব্যবহার করা হয় যা class-এর সম্পর্ক নির্দেশ করে।
- Super Class: যে class থেকে অন্য class property পায়।
Example: Animal হলো Dog-এর superclass। - Parent Class: যে class তার data ও function অন্য class-কে দেয়।
Example: Animal হলো parent class। - Base Class: Parent class-এর আরেকটি নাম।
Example: Animal হলো base class। - Derived Class: যে class অন্য class থেকে property নেয়।
Example: Dog হলো derived class। - Child Class: Parent class থেকে property গ্রহণকারী class।
Example: Dog হলো child class। - Subclass: Derived class-এর আরেকটি নাম।
Example: Dog হলো subclass।
Example:
class Animal {}; // Parent / Base / Super class
class Dog : public Animal {}; // Child / Derived class
[/urcr_restrict]

Single inheritance is the simplest type where a child class inherits from only one parent class.
Syntax:
class A {};
class B : public A {};
Example:
class Animal {
public:
Animal() {
cout<<"I am an animal.\n";
}
};
class Dog : public Animal {
public:
Dog() {
cout<<"I am a dog.\n";
}
};
int main() {
Dog obj;
}
Output:
I am an animal. I am a dog.
Explanation:
Dog inherits Animal, so parent constructor runs first, then child.
একটি child class শুধু একটি parent class থেকে inherit করে।
Example:
class Animal {
public:
Animal() {
cout<<"I am an animal.\n";
}
};
class Dog : public Animal {
public:
Dog() {
cout<<"I am a dog.\n";
}
};
Output:
I am an animal. I am a dog.
[urcr_restrict]
In multiple inheritance, a child class inherits from more than one parent class.
Syntax:
class A {};
class B {};
class C : public A, public B {};
Example:
class Animal {
public:
Animal() {
cout<<"I am an animal.\n";
}
};
class Speak {
public:
Speak() {
cout<<"I can speak.\n";
}
};
class Dog : public Animal, public Speak {};
int main() {
Dog obj;
}
Output:
I am an animal. I can speak.
Explanation:
Dog inherits both Animal and Speak → both constructors execute.
একটি child class একাধিক parent class থেকে inherit করে।
Example:
class Animal {
public:
Animal() {
cout<<"I am an animal.\n";
}
};
class Speak {
public:
Speak() {
cout<<"I can speak.\n";
}
};
class Dog : public Animal, public Speak {};
Output:
I am an animal. I can speak.
[/urcr_restrict]

In multilevel inheritance, a class is derived from another derived class.Here, class A is the parent class, class B is the child class, which is inherited from the parent class A, and class B is the parent class for class C, which is being inherited from class B.
Syntax:
class A {};
class B : public A {};
class C : public B {};
Example:
class Animal {
public:
Animal() {
cout<<"I am an animal.\n";
}
};
class Dog : public Animal {
public:
Dog() {
cout<<"I am a dog.\n";
}
};
class Pug : public Dog {
public:
Pug() {
cout<<"I am a pug.\n";
}
};
int main() {
Pug obj;
}
Output:
I am an animal. I am a dog. I am a pug.
Explanation:
Pug inherits Dog → Dog inherits Animal → chain execution happens.
একটি class আরেকটি derived class থেকে inherit করে।
Example:
class Animal {
public:
Animal() {
cout<<"I am an animal.\n";
}
};
class Dog : public Animal {
public:
Dog() {
cout<<"I am a dog.\n";
}
};
class Pug : public Dog {
public:
Pug() {
cout<<"I am a pug.\n";
}
};
Output:
I am an animal. I am a dog. I am a pug.
[urcr_restrict]
In hierarchical inheritance, multiple child classes inherit from one parent class.
Syntax:
class A {};
class B : public A {};
class C : public A {};
Example:
class Animal {
public:
Animal() {
cout<<"I am an animal.\n";
}
};
class Dog : public Animal {};
class Cat : public Animal {};
class Pig : public Animal {};
int main() {
Dog d;
Cat c;
Pig p;
}
Output:
I am an animal. I am an animal. I am an animal.
Explanation:
All child classes inherit from Animal → constructor called for each object.
একটি parent class থেকে একাধিক child class inherit করে।
Example:
class Animal {
public:
Animal() {
cout<<"I am an animal.\n";
}
};
class Dog : public Animal {};
class Cat : public Animal {};
class Pig : public Animal {};
Output:
I am an animal. I am an animal. I am an animal.
[/urcr_restrict]
- Suppose a base class is used to create two classes Parent1 and Parent2
- Both classes have a method sum()
- A child class inherits from both Parent1 and Parent2
- Now if child calls sum(), compiler gets confused → which one to call?
class S1 {
void sum(int x, int y) {
System.out.println(x + y);
}
}
class S2 {
void sum(int x, int y) {
System.out.println(x + y);
}
}
class D1 extends S1, S2 { // ERROR
}
Error:Error: multiple inheritance not supportedReason:
- Both S1 and S2 have same method → conflict occurs
- Compiler cannot decide which method to use
- Parent1 এবং Parent2-এ একই method আছে (sum)
- Child class দুইটাকেই inherit করলে
- sum() call করলে compiler বুঝতে পারে না কোনটা ব্যবহার করবে
class D1 extends S1, S2 {
// Error
}
কারণ:- একই method দুই class-এ থাকায় conflict হয়
- Compiler সিদ্ধান্ত নিতে পারে না
[urcr_restrict]
The Diamond Problem occurs in multiple inheritance when a class inherits from two classes that have a common base class, causing ambiguity.
Concept:
If a class inherits the same method from two different paths, the compiler becomes confused about which method to use.
Diagram (Diamond Shape):
Parent
/ \
Child1 Child2
\ /
GrandChild
Explanation:
- Parent has a method sum()
- Child1 and Child2 inherit sum()
- GrandChild inherits from both Child1 and Child2
- Now GrandChild gets two copies of sum()
Problem:
- When calling sum(), compiler cannot decide:
- Call from Child1 or Child2?
Example (Conceptual):
class Parent {
void sum() {
cout<<"Sum from Parent";
}
};
class Child1 : public Parent {};
class Child2 : public Parent {};
class GrandChild : public Child1, public Child2 {};
int main() {
GrandChild obj;
obj.sum(); // Ambiguity error
}
Error:
Error: ambiguous call to sum()
Why Java Avoids This:
- Java does not support multiple inheritance with classes
- This avoids ambiguity completely
Solution in C++:
- Use virtual inheritance
The Diamond Problem creates ambiguity in method calls, which is why languages like Java avoid multiple inheritance using classes.
Diamond Problem হলো multiple inheritance-এর একটি সমস্যা যেখানে একই parent class থেকে দুইটি path দিয়ে inheritance হওয়ার কারণে confusion তৈরি হয়।
Diagram:
Parent
/ \
Child1 Child2
\ /
GrandChild
ব্যাখ্যা:
- Parent class-এ sum() method আছে
- Child1 ও Child2 উভয়ই sum() inherit করে
- GrandChild দুই দিক থেকে sum() পায়
সমস্যা:
- GrandChild থেকে sum() call করলে compiler বুঝতে পারে না কোনটা ব্যবহার করবে
Example:
GrandChild obj; obj.sum(); // Error
কারণ:
- একই function দুইবার এসেছে
- Ambiguity তৈরি হয়েছে
Java কেন support করে না:
- Java multiple inheritance allow করে না
- এতে ambiguity এড়ানো যায়
Diamond problem inheritance-এ confusion তৈরি করে, তাই Java এটি এড়িয়ে চলে।
[/urcr_restrict]
OOP Properties : Polymorphism
Polymorphism is derived from two words: “Poly” (many) and “Morph” (forms). So, polymorphism means “many forms”.
In C++, polymorphism refers to the ability of a function or operator to behave differently depending on the context.
Real-Life Example:
- “I am right” → right = correct
- “Turn right” → right = direction
Same word → different meanings → this is polymorphism.
Example in C++ (+ Operator):
1. Addition of Numbers:
int a = 10; int b = 32; cout << a + b;
Output:
42
2. String Concatenation:
string a = "poly"; string b = "morphism"; cout << a + b;
Output:
polymorphism
Explanation:
The same + operator is used for:
- Adding numbers
- Joining strings
So, one operator behaves in multiple ways → Polymorphism.
Polymorphism makes programs more flexible and reusable by allowing the same function or operator to perform different tasks.
Polymorphism শব্দটি এসেছে “Poly” (অনেক) এবং “Morph” (রূপ) থেকে। অর্থাৎ এর মানে হলো “একাধিক রূপ”।
C++-এ polymorphism বলতে বোঝায় একই function বা operator বিভিন্নভাবে কাজ করা।
বাস্তব উদাহরণ:
- “I am right” → right = সঠিক
- “Turn right” → right = ডান দিক
একই শব্দ → ভিন্ন অর্থ → এটিই polymorphism।
C++ Example (+ Operator):
1. সংখ্যা যোগ:
int a = 10; int b = 32; cout << a + b;
Output:
42
2. String যোগ (Concatenation):
string a = "poly"; string b = "morphism"; cout << a + b;
Output:
polymorphism
ব্যাখ্যা:
একই + operator ব্যবহার করে:
- সংখ্যা যোগ করা যায়
- String যুক্ত করা যায়
তাই এটি polymorphism।
Overloaded functions are called by comparing the data types and number of parameters. This type of information is available to the compiler at the compile time. Thus, the suitable function to be called will be chosen by the C++ compiler at compilation time.
Achieved By:- Function Overloading: Same function name with different parameters.
- Operator Overloading: Same operator behaves differently for different data types.
class Example {
public:
int add(int a, int b) {
return a + b;
}
int add(int a, int b, int c) {
return a + b + c;
}
};
Example (Operator Overloading Concept):
The + operator works for both integers and strings (different behavior).Key Features:- Resolved at compile time
- Faster execution
- Achieved without inheritance
- Function Overloading: একই নামের function, কিন্তু parameter ভিন্ন
- Operator Overloading: একই operator বিভিন্নভাবে কাজ করে
int add(int a, int b); int add(int a, int b, int c);বৈশিষ্ট্য:
- Compile time-এ কাজ হয়
- দ্রুত execution
- Inheritance দরকার হয় না
Polymorphism in C++ is mainly divided into two types based on when the function call is resolved:
2. Dynamic Polymorphism (Run-time Polymorphism)
In dynamic polymorphism, the function call is resolved at runtime.
Runtime polymorphism occurs when functions are resolved at runtime rather than compile time when a call to an overridden method is resolved dynamically at runtime rather than compile time. It’s also known as late binding or dynamic binding
Achieved By:
- Method Overriding: Child class provides its own implementation of parent method.
- Virtual Functions: Enable late binding (decision at runtime).
Example (Method Overriding):
class Animal {
public:
virtual void sound() {
cout << "Animal sound" << endl;
}
};
class Dog : public Animal {
public:
void sound() {
cout << "Dog barks" << endl; } }; int main() { Animal* a; Dog d; a = &d; a->sound();
}
Output:
Dog barks
Key Features:
- Resolved at runtime
- Uses inheritance
- More flexible but slightly slower
Conclusion:
Static polymorphism provides speed and efficiency, while dynamic polymorphism provides flexibility and extensibility in programs.
2. Dynamic Polymorphism (Run-time)
এখানে function call runtime-এ নির্ধারিত হয়।
Runtime polymorphism তখন ঘটে যখন function call compile time-এ নয়, বরং runtime-এ resolve করা হয়।
যখন একটি overridden method call করা হয়, তখন কোন method execute হবে তা compile time-এ ঠিক না হয়ে runtime-এ dynamically নির্ধারিত হয়। অর্থাৎ program run করার সময় actual object-এর উপর ভিত্তি করে method call decide করা হয়।
এ কারণেই একে late binding বা dynamic binding বলা হয়।
যেভাবে করা হয়:
- Method Overriding: Child class নিজস্ব method দেয়
- Virtual Function: Runtime-এ method নির্ধারণ করে
Example:
class Animal {
public:
virtual void sound() {
cout<<"Animal sound";
}
};
class Dog : public Animal {
public:
void sound() {
cout<<"Dog barks";
}
};
বৈশিষ্ট্য:
- Runtime-এ কাজ হয়
- Inheritance ব্যবহার হয়
- Flexible কিন্তু একটু ধীর
উপসংহার:
Static polymorphism দ্রুত, আর dynamic polymorphism বেশি flexible।
[urcr_restrict]
Function Overloading is a feature of OOP where multiple functions have the same name but differ in parameters (type or number). The correct function is selected automatically by the compiler.
Definition:
When functions share the same name but differ in type or number of arguments, it is called function overloading.
Ways to Achieve Function Overloading:
- Different number of parameters
- Different types of parameters
Example:
class Temp {
int x = 10;
double x1 = 10.1;
public:
void add(int y) {
cout << x + y << endl;
}
void add(double d) {
cout << x1 + d << endl;
}
void add(int y, int z) {
cout << x + y + z << endl;
}
};
int main() {
Temp t;
t.add(10); // int version
t.add(11.1); // double version
t.add(12, 13); // two-parameter version
}
Output:
20 21.2 35
Explanation:
- t.add(10) → calls add(int)
- t.add(11.1) → calls add(double)
- t.add(12,13) → calls add(int, int)
The compiler selects the correct function based on argument type and number at compile time.
Key Features:
- Same function name
- Different parameters
- Resolved at compile time
Advantages:
- Improves code readability
- Reduces need for different function names
- Supports compile-time polymorphism
Conclusion:
Function overloading allows writing flexible and clean code by using the same function name for different tasks.
Function Overloading হলো এমন একটি পদ্ধতি যেখানে একই নামের একাধিক function থাকে কিন্তু তাদের parameter ভিন্ন হয়।
যেভাবে করা হয়:
- Parameter সংখ্যা ভিন্ন
- Parameter type ভিন্ন
Example:
void add(int y); void add(double d); void add(int y, int z);
ব্যাখ্যা:
- add(10) → int version call হয়
- add(11.1) → double version call হয়
- add(12,13) → দুই parameter version call হয়
বৈশিষ্ট্য:
- একই function নাম
- ভিন্ন parameter
- Compile time-এ সিদ্ধান্ত হয়
সুবিধা:
- Code সহজ ও readable হয়
- একই কাজের জন্য আলাদা নাম দরকার হয় না
- Compile-time polymorphism support করে
Function overloading ব্যবহার করে একই function দিয়ে বিভিন্ন কাজ করা যায়।
[/urcr_restrict]
Operator Overloading is a feature in C++ that allows operators to be redefined for user-defined data types (like objects).
Definition:
When an operator is used to perform special operations on objects instead of primitive data types, it is called operator overloading.
Important Rules:
- At least one operand must be a user-defined type.
- Some operators cannot be overloaded such as:
- . (dot)
- :: (scope resolution)
- ?: (ternary)
- sizeof, typeid
Operators that can be overloaded:
- Arithmetic: +, -, *, /, %
- Relational: ==, !=, >, <, >=, <=
- Logical: &&, ||
- Bitwise: &, |, ^, <<, >>
- Memory: new, delete
Example (Overloading ++ Operator):
class Count {
int x;
public:
Count(int X = 0) {
x = X;
}
Count operator++() {
Count c;
c.x = ++x;
return c;
}
void print() {
cout << x << endl;
}
};
int main() {
Count c1(42);
c1.print();
Count c2 = ++c1;
c2.print();
}
Output:
42 43
Explanation:
- c1(42) → initializes x = 42
- ++c1 → calls overloaded operator++()
- Value increases to 43
- New object c2 gets updated value
Advantages:
- Makes code more readable and natural
- Allows operators to work with objects
- Supports polymorphism
Disadvantages:
- Overuse can make code confusing
- Complex implementation for beginners
Operator overloading makes it possible to use operators with user-defined objects, improving flexibility and readability of programs.
Operator Overloading হলো এমন একটি পদ্ধতি যেখানে operator-কে user-defined object-এর জন্য নতুনভাবে ব্যবহার করা যায়।
সংজ্ঞা:
যখন operator object-এর উপর বিশেষ কাজ করে, তখন তাকে operator overloading বলা হয়।
নিয়ম:
- কমপক্ষে একটি operand অবশ্যই user-defined type হতে হবে
- কিছু operator overload করা যায় না:
- ., ::, ?:, sizeof
যেসব operator overload করা যায়:
- Arithmetic: +, -, *, /
- Relational: ==, !=, >, <
- Logical: &&, ||
- Bitwise: &, |, <<, >>
- Memory: new, delete
Example:
Count operator++() {
Count c;
c.x = ++x;
return c;
}
ব্যাখ্যা:
- ++ operator object-এর জন্য redefine করা হয়েছে
- Value 42 → 43 হয়েছে
- নতুন object-এ value store হয়েছে
সুবিধা:
- Code readable হয়
- Object-এর সাথে operator ব্যবহার করা যায়
- Flexible programming
অসুবিধা:
- ভুল ব্যবহার করলে code confusing হতে পারে
- শিখতে একটু কঠিন
Operator overloading ব্যবহার করে object-এর সাথে operator সহজে ব্যবহার করা যায়।
Function Overriding occurs when a derived class defines a function with the same name, same parameters, and same return type as in the base class.
Key Point:
Without using virtual, function calls are resolved at compile time (static binding).
Example Result:
Area of Rectangle is: 0 Area of Triangle is: 0 Area of Polygon is: 0
Explanation:
- Pointer type is Polygon*, so base class function is called.
- Derived class functions are ignored.
- This happens due to static binding.
Conclusion:
Without virtual, overriding does not work properly for runtime polymorphism.
Function Overriding তখন হয় যখন child class একই নাম ও parameter-এর function ব্যবহার করে।
মূল বিষয়:
Virtual keyword না থাকলে function call compile time-এ নির্ধারিত হয়।
Output:
0 0 0
ব্যাখ্যা:
- Pointer Polygon type হওয়ায় base class function call হয়
- Derived class function call হয় না
উপসংহার:
Virtual ছাড়া runtime polymorphism ঠিকভাবে কাজ করে না।
[urcr_restrict]
A virtual function is a function declared in the base class using the keyword virtual.
Key Idea:
With virtual, function call is resolved at runtime (dynamic binding).
Example Output:
Area of Rectangle is: 200 Area of Triangle is: 100 Area of Polygon is: 0
Explanation:
- ppoly1 → Rectangle function
- ppoly2 → Triangle function
- Correct function is selected at runtime
Virtual functions enable true runtime polymorphism.
Virtual Function হলো base class-এর একটি function যা virtual keyword দিয়ে ঘোষণা করা হয়।
মূল ধারণা:
Function call runtime-এ নির্ধারিত হয় (dynamic binding)।
Output:
200 100 0
ব্যাখ্যা:
- Rectangle-এর জন্য rectangle function call হয়
- Triangle-এর জন্য triangle function call হয়
Virtual function ব্যবহার করলে runtime polymorphism সঠিকভাবে কাজ করে।
[/urcr_restrict]
A pure virtual function is a virtual function declared with = 0 and has no implementation in the base class.
Syntax:
class Base {
public:
virtual void func() = 0;
};
Key Idea:
- Derived class must implement this function
- Otherwise → compilation error
Example Output:
Inside derived class
Explanation:
- Base pointer points to Derived object
- Derived class function is called
Pure virtual functions are used to create abstract classes and enforce implementation in derived classes.
Pure Virtual Function হলো এমন একটি function যার base class-এ কোন implementation নেই।
Syntax:
virtual void func() = 0;
মূল বিষয়:
- Derived class-এ implement করতেই হবে
- না করলে error হবে
Output:
Inside derived class
ব্যাখ্যা:
- Base pointer → Derived object
- Derived class function call হয়
Pure virtual function ব্যবহার করে abstract class তৈরি করা হয়।
| Compile-Time Polymorphism | Run-Time Polymorphism |
|---|---|
| Function call is resolved at compile time | Function call is resolved at runtime |
| Also known as Static/Early Binding | Also known as Dynamic/Late Binding |
| Achieved by function overloading | Achieved by virtual functions & overriding |
| Faster execution | Slower execution |
| Less flexible | More flexible |
| No inheritance required | Requires inheritance |
Conclusion:
Compile-time polymorphism is fast and simple, while run-time polymorphism is flexible and dynamic.
| Compile-Time Polymorphism | Run-Time Polymorphism |
|---|---|
| Function call compile time-এ নির্ধারিত হয় | Function call runtime-এ নির্ধারিত হয় |
| Static/Early Binding | Dynamic/Late Binding |
| Function overloading দ্বারা হয় | Virtual function ও overriding দ্বারা হয় |
| দ্রুত execution | তুলনামূলক ধীর |
| কম flexible | বেশি flexible |
| Inheritance দরকার নেই | Inheritance দরকার |
উপসংহার:
Compile-time polymorphism দ্রুত, আর run-time polymorphism বেশি flexible।
| Function Overloading | Function Overriding |
|---|---|
| Provides multiple definitions by changing function signature | Redefines base class function in derived class |
| Example of compile-time polymorphism | Example of run-time polymorphism |
| Function signatures must be different | Function signatures must be same |
| Functions exist in same scope | Functions exist in different scopes |
| Used when same function behaves differently based on parameters | Used when child class changes behavior of parent function |
| Can be overloaded multiple times | Function is overridden once in derived class |
| No inheritance required | Requires inheritance |
Conclusion:
Function overloading is used for flexibility with parameters, while function overriding is used for modifying inherited behavior.
| Function Overloading | Function Overriding |
|---|---|
| Signature পরিবর্তন করে একাধিক function তৈরি করা হয় | Parent class-এর function child class-এ নতুনভাবে লেখা |
| Compile-time polymorphism | Run-time polymorphism |
| Function signature ভিন্ন হতে হবে | Function signature একই হতে হবে |
| একই scope-এ থাকে | ভিন্ন scope-এ থাকে |
| Parameter অনুযায়ী behavior পরিবর্তন হয় | Child class parent function পরিবর্তন করে |
| একাধিকবার overload করা যায় | একবার override করা হয় |
| Inheritance দরকার নেই | Inheritance দরকার |
উপসংহার:
Overloading parameter অনুযায়ী কাজ করে, আর overriding inheritance-এর মাধ্যমে behavior পরিবর্তন করে।
Constructor & Destructor
A constructor is a special member function of a class that is automatically called when an object of the class is created.
Main Features of Constructor:
- Constructor name is same as the class name.
- It has no return type (not even void).
- It is automatically executed when object is created.
- Used to initialize variables of a class.
Purpose:
Constructors are mainly used to assign initial values to class data members when an object is created.
Example (C++):
class Line {
public:
Line(); // Constructor
};
Line::Line() {
cout << "Object is being created" << endl;
}
Explanation:
- When object Line line; is created, constructor is called automatically.
- It prints → “Object is being created”
- Then other member functions can be used.
Output:
Object is being created Length of line : 6
Types of Constructors:
- Default Constructor: No parameters.
- Parameterized Constructor: Takes arguments.
- Copy Constructor: Copies one object to another.
Constructor হলো একটি special member function যা object তৈরি হওয়ার সাথে সাথে automatically call হয়।
মূল বৈশিষ্ট্য:
- Constructor-এর নাম class-এর নামের মতোই হয়।
- এর কোন return type নেই (void-ও না)।
- Object তৈরি হলেই এটি automatic run হয়।
- Class-এর variable initialize করতে ব্যবহৃত হয়।
উদ্দেশ্য:
Object তৈরি করার সময় data member-গুলোকে initial value দেওয়া।
Example:
Line::Line() {
cout << "Object is being created" << endl;
}
ব্যাখ্যা:
- Line line; লিখলে constructor call হয়।
- এটি print করে → “Object is being created”
- তারপর অন্যান্য function ব্যবহার করা যায়।
Output:
Object is being created Length of line : 6
Constructor-এর ধরন:
- Default Constructor: কোন parameter নেই
- Parameterized Constructor: parameter থাকে
- Copy Constructor: একটি object থেকে আরেকটি তৈরি করে
className() {
// initialization code
}
Example:class Example {
public:
int a, b;
Example() {
a = 10;
b = 20;
}
};
int main() {
Example obj;
cout << obj.a << " " << obj.b;
}
Output:10 20Key Points:
- No arguments required.
- Automatically called during object creation.
- Can be defined by programmer or provided by compiler.
- Initialize objects with default values.
- Create objects without passing parameters.
- Ensures object is initialized.
- Simple and easy to use.
- Not suitable when specific values are required.
className() {
// initialization
}
Example:class Example {
public:
int a, b;
Example() {
a = 10;
b = 20;
}
};
মূল বিষয়:- কোন argument লাগে না
- Object তৈরি হলেই automatic call হয়
- Programmer বা compiler উভয়ই তৈরি করতে পারে
- Default value দিয়ে object initialize
- Parameter ছাড়া object তৈরি
- Object সবসময় initialized থাকে
- ব্যবহার সহজ
- Specific value দরকার হলে উপযোগী নয়
A parameterized constructor is a constructor that accepts arguments to initialize objects with specific values at the time of creation.
Definition:
It allows passing values to initialize data members when an object is created.
Syntax:
className(parameters...) {
// initialization
}
Example:
class Point {
int x, y;
public:
Point(int x1, int y1) {
x = x1;
y = y1;
}
int getX() { return x; }
int getY() { return y; }
};
int main() {
Point p1(10, 15);
cout << p1.getX() << " " << p1.getY();
}
Output:
10 15
Key Points:
- Accepts arguments during object creation.
- Used to initialize objects with specific values.
- Can be called implicitly or explicitly.
Important Note:
If only parameterized constructor is defined, then:
- You must pass arguments when creating objects.
- Compiler will not create default constructor automatically.
Applications:
- Initialize objects with user-defined values.
- Set different initial states for different objects.
Advantages:
- Provides flexibility in object initialization.
- More meaningful and controlled data assignment.
Disadvantages:
- Object creation requires parameters.
- No default object creation unless default constructor is defined
Parameterized constructor allows creating objects with custom values, making programs more flexible and powerful.
Parameterized Constructor হলো এমন একটি constructor যা parameter গ্রহণ করে এবং object তৈরি করার সময় নির্দিষ্ট value সেট করে।
সংজ্ঞা:
Object তৈরি করার সময় data member-এ specific value assign করতে ব্যবহৃত হয়।
Syntax:
className(parameters...) {
// initialization
}
Example:
class Point {
int x, y;
public:
Point(int x1, int y1) {
x = x1;
y = y1;
}
};
মূল বিষয়:
- Object তৈরি করার সময় parameter দিতে হয়
- Specific value initialize করা যায়
- Implicit বা explicit ভাবে call করা যায়
গুরুত্বপূর্ণ বিষয়:
- Default constructor না থাকলে parameter ছাড়া object তৈরি করা যাবে না
- Compiler নিজে default constructor তৈরি করবে না
ব্যবহার:
- Custom value দিয়ে object তৈরি
- Different object-এর জন্য ভিন্ন initial state সেট কর
সুবিধা:
- Flexible initialization
- Meaningful data assignment
অসুবিধা:
- Parameter ছাড়া object তৈরি করা যায় না
- Default constructor না থাকলে সমস্যা হয়
Parameterized constructor ব্যবহার করে custom ও flexible object initialization করা যায়।
A copy constructor is a special constructor that initializes an object using another object of the same class.
Definition:
It creates a new object by copying the values of an existing object.
Syntax:
ClassName (ClassName &obj) {
// copy data
}
Key Points:
- Takes a reference of same class object as argument.
- Used to copy one object into another.
- Compiler provides an implicit copy constructor if not defined.
Example (Implicit Copy Constructor):
class Sample {
int id;
public:
Sample(int x) { id = x; }
void display() { cout << "ID=" << id; }
};
int main() {
Sample obj1(10);
Sample obj2(obj1); // copy constructor
obj2.display();
}
Output:
ID=10
Example (Explicit Copy Constructor):
class Sample {
int id;
public:
Sample(int x) { id = x; }
Sample(Sample &t) {
id = t.id;
}
void display() { cout << "ID=" << id; }
};
When Copy Constructor is Used:
- When an object is initialized from another object.
- When an object is passed to a function by value.
- When an object is returned from a function.
Advantages:
- Ensures correct copying of object data.
- Useful for managing dynamic memory safely.
Disadvantages:
- Can cause overhead if copying large objects.
Copy constructor helps in creating duplicate objects with same values, ensuring proper object handling in programs.
Copy Constructor হলো এমন একটি constructor যা একটি object-এর মান অন্য object-এ copy করে।
সংজ্ঞা:
একটি নতুন object তৈরি করে যেখানে অন্য একটি object-এর data কপি করা হয়।
Syntax:
ClassName (ClassName &obj) {
// copy
}
মূল বিষয়:
- একই class-এর object reference নেয়
- এক object থেকে আরেক object তৈরি করে
- না লিখলে compiler নিজে implicit constructor দেয়
Example:
Sample obj1(10); Sample obj2(obj1);
কখন ব্যবহার হয়:
- এক object থেকে আরেক object initialize করলে
- Function-এ object pass করলে
- Function থেকে object return করলে
সুবিধা:
- ঠিকভাবে data copy হয়
- Memory management-এ সাহায্য করে
অসুবিধা:
- বড় object হলে performance কমতে পারে
Copy constructor ব্যবহার করে সহজে একই মানের নতুন object তৈরি করা যায়।
class ClassName {
public:
~ClassName() {
// cleanup code
}
};
Key Characteristics:- Same name as class but preceded by ~ (tilde)
- Has no return type
- Takes no parameters
- Called automatically by compiler
- Cannot be overloaded
class Demo {
public:
Demo() {
cout << "Constructor called\n";
}
~Demo() {
cout << "Destructor called\n";
}
};
int main() {
Demo obj;
Output:Constructor called Destructor calledOrder of Execution: Destructors are called in reverse order of constructors (LIFO principle).Example:
Department d1; Employee e2;Output:
Constructor Invoked for Department class Constructor Invoked for Employee class Destructor Invoked for Employee class Destructor Invoked for Department classExplanation:
- First, constructors are called in order of object creation.
- Then destructors are called in reverse order.
- This follows Stack (LIFO) behavior.
- Free dynamically allocated memory
- Close files or network connections
- Clean up resources
- Automatic resource management
- Prevents memory leaks
~ClassName() {
// cleanup
}মূল বৈশিষ্ট্য:- Class-এর নামের আগে ~ থাকে
- কোন return type নেই
- কোন parameter নেই
- Automatic call হয়
- Overload করা যায় না
class Demo {
public:
Demo() {
cout<<"Constructor";
}
~Demo() {
cout<<"Destructor";
}
};Execution Order:
Destructor সবসময় reverse order-এ (LIFO) call হয়।Example Output:Constructor Department Constructor Employee Destructor Employee Destructor Departmentব্যাখ্যা:
- Constructor আগে call হয়
- Destructor পরে reverse order-এ call হয়
- Memory free করা
- File close করা
- Resource cleanup
- Automatic memory management
- Memory leak কমায়
| S.No | Constructor | Destructor |
|---|---|---|
| 1 | Called to initialize object | Called when object is destroyed |
| 2 | Declared as ClassName() | Declared as ~ClassName() |
| 3 | Can accept parameters | No parameters |
| 4 | Used to assign values to data members | Used to free memory/resources |
| 5 | Can have multiple constructors | Only one destructor |
| 6 | Can be overloaded | Cannot be overloaded |
Conclusion:
Constructor is used for object creation and initialization, while destructor is used for cleanup and memory release.
| ক্রম | Constructor | Destructor |
|---|---|---|
| 1 | Object initialize করতে ব্যবহৃত | Object destroy হলে call হয় |
| 2 | ClassName() দিয়ে লেখা হয় | ~ClassName() দিয়ে লেখা হয় |
| 3 | Parameter নিতে পারে | Parameter নেয় না |
| 4 | Data member-এ value assign করে | Memory free করে |
| 5 | একাধিক constructor থাকতে পারে | একটি destructor থাকে |
| 6 | Overload করা যায় | Overload করা যায় না |
উপসংহার:
Constructor object তৈরি ও initialize করে, আর destructor object শেষ হলে memory cleanup করে।
Previous Question on OOP
- OOP Concepts / Features
- Properties of OOP. [TSS-AP-2023]
- Explain OOP features. [DPDC(AE)-25]
- What are the basic features of object-oriented concepts? Give example code for each of them. [BPSC(AME)-24]
- What are the basic Concepts used in the Object oriented Programming language? [Uttara Bank(AP)-2019] [Pally Sa.-2018]
- Write down the Principle of OOP. What is Polymorphism? Write the name of 3 OOP language. [DESCO SAE 2023; 40th BCS 2021]
- কী কী ধারণার উপর ভিত্তি করে OOP প্রতিষ্ঠিত? ধারণাগুলো ব্যাখ্যা করুন। [17th NTRCA(CSE) 2023]
- Core OOP Features
- Briefly describe Abstraction, Encapsulation, Inheritance and polymorphism. [Competition Commition(P)-2019]
- Object oriented programming এর যে কোন দুটি বৈশিষ্ট্য উদাহরণসহ ব্যাখ্যা করুন। [BPSC-(M.o.Commercee)-2021]
- Explain how encapsulation and inheritance are advantageous in object oriented programming. [Com. Ofc(IT-24)]
- Briefly Describe Abstraction, Encapsulation. [BCC Programmer 2019]
- OOP Concepts / Features
- Polymorphism
- What is polymorphism in the context of an object-oriented paradigm? Explain the method of overloading and method of overriding with suitable examples. [Ministry of Food, Network/Website Manager(ICT)2025]
- What is Polymorphism? Discuss different types of Polymorphism with examples. [CB,AP, 2024] [Combined Bank, AP 2024]
- Define Method Overloading and Method Overriding with examples. [BPSC AP, 17th NTRCA(ICT) 2023; Bank SO(AME), RAKUB Programmer, BPSC AME 2021; NU AP 2020]
- Difference between method overloading and overriding in java. [Agrani (o.)-2017] [DBBL-2016]
- What is Polymorphism? Java language এর আলোকে ব্যাখ্যা কর। [BTCL, JAM 2022]
- Inheritance
- Explain the concept of inheritance in Object-Oriented Programming. Name and briefly describe three common types of inheritance used in OOP. [CB-AP-2026]
- What is the Inheritance? What are the types of Inheritance in Java? [IBBL(Software)-2019]
- Inheritance is one of important issues of any object oriented programming language. Explain in brief different types of inheritance. [officer(SBL-JBL-IT)-2020] [Combined Bank, Officer(IT) 2020]
- Inheritance কী? উদাহরণসহ ব্যাখ্যা করুন। [17th NTRCA(CSE) 2023]
- How many classes can be used in Hybrid Inheritance? [BCC AP 2023]
- What is the diamond problem of multiple Inheritance in C++? [BPSC AP 2023]
- Encapsulation / Access Specifiers
- You have three access specifiers in java object oriented language. Public, Private and Protected Mode (Y/N). [PetroBangla (AE-24)]
- What are the various Access Specification in C++? Explain their purpose with example. [BPSC, ADA 2022]
- Class & Object / Structure
- Difference between Class and Structure. [BCIC(AP-25)]
- উদাহরণসহ Class এবং Object এর মধ্যে পার্থক্য ব্যাখ্যা করুন। [17th NTRCA(CSE), (ICT) 2023]
- Constructor / Destructor
- What is a constructor? How many types of constructors are used in Java? [IBBL(Software)-2019]
- Differentiate constructor and destructor with example. [Pally Sa.-2018]
- Binding & Functions
- Object oriented programming এ Static binding ও Dynamic binding কি? ব্যাখ্যা করুন? [BPSC-(M.o.Commercee)-2021]
- What is virtual function with example? [BITAC AP 2023]
- OOP vs Structured Programming
- Problem solving technique এর সংজ্ঞা দিন। Structured programming এবং object-oriented programming এর পার্থক্যগুলো লিখুন [45 BCS, Computer Science]
- Differences between Structured & object oriented programming? write down 2 examples of both language. [AP ICT ministry-2021]
- Write the differences between structured programming and object-oriented programming. [45th BCS CSE 2024; Bank SO(AME) 2021]
- Write down the advantages of OOP over traditional structured programming language. [Combined Bank Officer(IT) 2023]
