What is Object-Oriented Programming (OOP)?
OOP is a programming paradigm that organizes software design around objects (which hold data) and methods (which perform operations on that data) rather than just linear functions and logic.
Core OOP concepts, the four pillars, classes and interfaces, polymorphism, inheritance, and memory — top interview questions for college students and freshers preparing for IT placements in 2026.
OOP is a programming paradigm that organizes software design around objects (which hold data) and methods (which perform operations on that data) rather than just linear functions and logic.
The four core principles are Encapsulation, Abstraction, Inheritance, and Polymorphism.
A class is a logical blueprint or template (e.g., a car design). An object is a physical, real-world instance of that class (e.g., a specific Honda Civic) that occupies memory.
Procedural programming (like C) focuses on functions, global data, and a top-down approach. OOP (like Java or C++) focuses on data security (encapsulation), modular objects, and follows a bottom-up approach.
Encapsulation is the bundling of data (variables) and methods into a single unit (a class). It restricts direct access to internal states to prevent accidental modification, typically using private variables and public getter/setter methods.
Abstraction hides internal implementation complexity and shows only necessary interfaces (e.g., pressing a car accelerator without knowing how the engine works). Encapsulation hides the data itself to protect it from outside interference.
Polymorphism means "many forms." It allows objects of different classes to be treated as instances of the same class through a common interface, and allows a single method name to behave differently based on the object calling it.
Compile-time (static): The method to be invoked is determined by the compiler before execution (e.g., method overloading). Run-time (dynamic): The method to be invoked is determined at execution time based on the object type (e.g., method overriding).
Method overloading: Multiple methods in the same class share the exact same name but have different parameters. Method overriding: A child class provides its own specific implementation of a method already defined in its parent class.
Inheritance is a mechanism where a new child class derives properties and behaviors from an existing parent class, promoting code reusability. Types include single, multilevel, hierarchical, multiple, and hybrid.
The diamond problem occurs in multiple inheritance when a class inherits from two parent classes that both inherit from the same grandparent class. If both parents override a grandparent's method, the compiler cannot resolve which version the child should inherit.
An abstract class can have both implemented and unimplemented methods, and can hold state (variables). An interface acts as a strict contract containing only abstract methods (traditionally) and has no state. A class can implement multiple interfaces but inherit only one abstract class.
Access modifiers define the visibility of class members.
A virtual function is a method declared in a parent class that is explicitly intended to be overridden by a child class. It ensures that the correct child-class method is executed at runtime, even if the object is called through a parent-class reference.
A constructor is a special method automatically invoked when an object is created to initialize its state. It shares the exact name as the class and has no return type. Common types are default, parameterized, and copy constructors.
Yes. A private constructor prevents other classes from instantiating the object. This is widely used in the Singleton design pattern to ensure only one instance of a class exists in the entire application.
A destructor is a special method called automatically when an object is destroyed or goes out of scope. It is used to free memory or release resources held by the object (widely used in C++; languages like Java use garbage collection instead).
In C++, all members of a class are private by default, prioritizing data security. Members of a structure are public by default. Classes are suited for complex objects, while structures are typically used for simple data groupings.
The this keyword is a reference variable that refers to the current object invoking the method. It is commonly used to distinguish between class attributes and method parameters when they share the same name.
A friend function (in C++) is a function that is not a member of a class but is granted explicit access to its private and protected members. It is useful for operator overloading or when a function needs to access the internals of two different classes.
Interviewers often ask how your primary language differs from others on inheritance, polymorphism, and memory.
| Feature | C++ | Java | Python |
|---|---|---|---|
| Default access modifier | private for class, public for struct | Package-private (default) for classes; public for interfaces | Public by convention (_protected, __private name mangling) |
| Multiple inheritance of classes | Supported (virtual inheritance for diamond) | Not for classes; multiple interfaces | Supported (C3 linearization / MRO) |
| Runtime polymorphism default | Non-virtual by default; use virtual | Virtual by default (except private/static/final) | Duck typing — dynamic dispatch |
| Memory deallocation | delete or RAII smart pointers | Generational garbage collection (JVM) | Reference counting + cycle GC |
| Operator overloading | Supported (+, ==, <<, etc.) | Not supported (except String +) | Dunder methods (__add__, __eq__) |
| Pure abstract contract | Pure virtual (= 0) | interface / abstract class | abc.ABC + @abstractmethod |
From verbal pillars at mass recruiters to LLD and machine coding at product companies.
| Category | Companies | Interview focus | Practice tasks |
|---|---|---|---|
| Mass service recruiters | TCS (Ninja/Digital), Infosys, Wipro, Cognizant, Capgemini, Accenture | 15–20 min rapid-fire Q&A + small snippets with inheritance/overriding traps. | Class showing four pillars; predict output with constructor chaining (`super()` / base init list). |
| Mid-tier & console-app tech | Zoho (console round), LTIMindtree, Persistent, Thoughtworks, Juspay | Console OOP machine coding (60–180 min): modular app without spaghetti if-else. | Railway booking, parking lot, or library system with clean classes and relationships. |
| Tier-1 product & global tech | Amazon, Microsoft, Oracle, Flipkart, Walmart, Atlassian, Uber | LLD: SOLID, extensibility, patterns, concurrency, immutability. | Thread-safe singleton, immutable class, LRU class design, Strategy/Factory payment service. |