Object Oriented Programming
1. Basic Conceptual Questions
What is Object-Oriented Programming (OOP)?
What are the four main pillars of OOP?
How is OOP different from procedural programming?
What are classes and objects in C++?
What is the difference between structure (struct) and class (class) in C++?
What is encapsulation? How does it enhance security?
Explain abstraction with an example.
What is polymorphism? How is it achieved in C++?
What is inheritance? How does it help in code reusability?
Can we create an object of a class without defining it?
2. Inheritance-Based Questions
What are the different types of inheritance in C++?
What is the difference between private, protected, and public inheritance?
What happens when a derived class has a member function with the same name as the
base class?
What is virtual inheritance? Why is it needed?
Explain the diamond problem in C++ and how it can be solved.
What happens if the base class constructor is private? Can it still be inherited?
Can a constructor be inherited in C++?
3. Polymorphism-Based Questions
What is function overloading?
What is operator overloading? Give an example.
What is function overriding? How is it different from function overloading?
What is a virtual function?
What happens if a destructor is not declared as virtual in an inheritance
hierarchy?
What is a pure virtual function?
What is an abstract class?
Can we have a pure virtual destructor? If yes, why do we need it?
----------------------------------------------------------------------------
4. Encapsulation & Abstraction-Based Questions
How does encapsulation help in achieving abstraction?
Can we access private members of a class outside the class?
What are getter and setter methods? Why are they used?
Can a class have all private members? If yes, how will objects interact with it?
What is the difference between a friend function and a member function?
5. Constructors & Destructors
What are constructors?
What are the different types of constructors in C++?
What is a copy constructor? When is it called?
What is the difference between a deep copy and a shallow copy?
When do we need to define our own copy constructor?
Can a constructor be private? If yes, when would you use it?
What is a destructor? When is it called?
Can we have a static constructor in C++?
6. Memory Management & Dynamic Allocation
What is the difference between new and malloc()?
What is the difference between delete and delete[]?
What are smart pointers? Explain unique_ptr, shared_ptr, and weak_ptr.
What happens if a constructor throws an exception?
How can we avoid memory leaks in C++?
What is RAII (Resource Acquisition Is Initialization)?
7. Virtual Functions & VTables
What is a virtual table (vtable)?
How does C++ implement runtime polymorphism using vtable and vptr?
What happens if a derived class does not override a virtual function of the base
class?
Can constructors be virtual in C++?
How does C++ resolve function calls when multiple inheritance is involved?
8. Static Members & Friend Functions
What are static variables in a class?
Can a static function access non-static members of a class?
What is a friend function? When would you use it?
What is the difference between a friend class and a friend function?
9. Advanced & Scenario-Based Questions
How can we prevent a class from being inherited?
How can we prevent object instantiation of a class?
What is the CRTP (Curiously Recurring Template Pattern) in C++?
How can we implement a singleton class in C++?
What is the rule of three, five, and zero in C++?
Can an abstract class have a constructor?
Explain covariant return types in function overriding.
What is object slicing? How can we prevent it?
10. Coding-Based Questions
Basic Coding Questions
Write a class in C++ that represents a Bank Account with deposit and withdrawal
functionalities.
Write a program to demonstrate constructor overloading.
Implement a class with getter and setter functions to access private members.
Intermediate Coding Questions
Implement a class hierarchy for different types of employees (e.g., full-time,
part-time) using inheritance.
Write a program demonstrating function overriding and runtime polymorphism.
Implement operator overloading for the + operator in a complex number class.
Advanced Coding Questions
Write a smart pointer class to handle dynamic memory.
Implement a deep copy constructor for a class that dynamically allocates memory.
Implement a thread-safe Singleton class in C++.
11. Miscellaneous & Trick Questions
Can a destructor be private? If yes, in what scenario?
Why can’t constructors be virtual?
What will happen if we don’t write a copy constructor but use = assignment?
What are explicit constructors in C++?
What is multiple dispatch? Does C++ support it?
How can you call the base class constructor from the derived class?
Can a function be both virtual and inline?
How do you implement dynamic polymorphism without virtual functions?
Can a function return an object of a class by reference?
What is delegating constructor in C++?
Wrap-Up Questions
How would you explain OOP concepts to a non-technical person?
What are some real-world applications of OOP?
When should we not use OOP?
How can we make C++ code more maintainable and scalable using OOP?