Alright Maham, here's a full easy-breezy OOP viva prep — everything important in bullet points 👇
Keep this flow in your mind for viva — sounds confident, humble, and to the point.
🔹 Definition
-
OOP stands for Object-Oriented Programming
-
It's a method of writing code using objects (like real-world things)
-
It makes code modular, reusable, secure, and easy to manage
🔹 Core Concepts (4 Pillars)
-
Class
-
Blueprint or design of an object
-
Eg:
Carclass has color, speed, engine type
-
-
Object
-
Real thing created from a class
-
Eg:
myCar = Car()→ This is an object
-
-
Encapsulation
-
Wrapping data + functions inside one unit
-
Hides internal details (like a capsule)
-
Uses private/public access
-
-
Inheritance
-
Child class gets features of parent class
-
Reduces code repetition
-
Eg:
Doginherits fromAnimal
-
-
Polymorphism
-
One function behaves in different ways
-
Eg:
draw()can draw circle or square -
Types: Compile-time (overloading), Run-time (overriding)
-
-
Abstraction
-
Hides complex logic, shows only necessary part
-
Eg: You drive a car without knowing engine code
-
Uses abstract classes/interfaces
-
🔹 Other Important Concepts
-
Constructor
-
Special function that runs when object is created
-
Eg:
__init__()in Python, same name as class in Java/C++
-
-
Destructor
- Cleans up memory when object is destroyed
-
Method Overloading (Same name, different parameters - compile time)
-
Method Overriding (Same name, same parameters - runtime)
-
Access Modifiers
-
Control who can access what
-
public,private,protected
-
-
Interface
-
Just like a contract: tells what must be done
-
No body, only function names — class must implement it
-
-
Abstract Class
-
Has some code + some functions without code
-
Cannot make object of abstract class
-
-
Static
-
Belongs to class, not object
-
Eg:
static int count = 0;
-
-
This / Self
-
Refers to current object
-
thisin Java/C++,selfin Python
-
🔹 Benefits of OOP
-
Real-world modelling
-
Reusability
-
Easy maintenance
-
Secure coding
-
Less redundancy
Want viva-ready one-liners or examples also?