Short viva

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)

  1. Class

    • Blueprint or design of an object

    • Eg: Car class has color, speed, engine type

  2. Object

    • Real thing created from a class

    • Eg: myCar = Car() → This is an object

  3. Encapsulation

    • Wrapping data + functions inside one unit

    • Hides internal details (like a capsule)

    • Uses private/public access

  4. Inheritance

    • Child class gets features of parent class

    • Reduces code repetition

    • Eg: Dog inherits from Animal

  5. Polymorphism

    • One function behaves in different ways

    • Eg: draw() can draw circle or square

    • Types: Compile-time (overloading), Run-time (overriding)

  6. 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

    • this in Java/C++, self in Python


🔹 Benefits of OOP

  • Real-world modelling

  • Reusability

  • Easy maintenance

  • Secure coding

  • Less redundancy


Want viva-ready one-liners or examples also?

Updated on