Interview questions
Object-Oriented Programming (OOP) Interview Questions
18 OOPs interview questions on classes, encapsulation, inheritance, polymorphism and design principles, with model answers for candidates and interviewers.

What's here
18 Object-Oriented Programming (OOP) interview questions, grouped into 4 areas: the four pillars, classes, interfaces and language details, design principles and applied questions. Each one comes with why it is worth asking and what a strong answer contains, so the same question can be scored the same way by different interviewers.
- Ask for an example after every definition; reciting the four pillars is easy, applying them is not
- Use a short low-level design exercise to see how the candidate models objects and responsibilities
- Probe the abstract class versus interface answer in the language the team actually uses
Cohesyve finds, contacts and tests Object-Oriented Programming candidates on the real work, then ranks them for these interviews. 14-day free trial for 10 candidates, not charged until it ends.
Preparing for this interview yourself? Practise it free →OOPs interview questions (object-oriented programming) come up in almost every software developer interview, whether the language is Java, C#, Python, C++ or TypeScript. Interviewers use them to check that a candidate can model a problem with classes and objects, knows the four pillars well enough to explain the trade-offs, and can apply design principles to real code. The 'what to look for' notes double as model answers for candidates and a scoring guide for interviewers. Examples use Java and Python, but the ideas carry across languages.
The Four Pillars
Encapsulation, abstraction, inheritance and polymorphism: the questions every OOP interview opens with.
- 1
What is the difference between a class and an object?
Why ask it
A basic check that the candidate can explain fundamentals clearly.What to look for
A class is a blueprint that defines state (fields) and behaviour (methods); an object is a specific instance of that class with its own state in memory. Example: a Car class and two car objects with different colours. Good answers mention constructors as the way objects are initialised. - 2
What is encapsulation, and why does it matter?
Why ask it
Encapsulation is the pillar most often confused with abstraction.What to look for
Bundling data with the methods that operate on it and restricting direct access to internal state, usually with private fields and public methods. It protects invariants (a bank balance cannot be set to an invalid value), reduces coupling and lets internals change without breaking callers. Strong candidates note that Python relies on convention (a leading underscore) and name mangling for double underscores, which avoids accidents but does not enforce privacy. - 3
How is abstraction different from encapsulation?
Why ask it
A classic follow-up that separates understanding from definitions.What to look for
Abstraction is about exposing only what a caller needs (what an object does), hiding complexity behind an interface or abstract class. Encapsulation is about how state is protected inside the object. A payment interface with a pay() method is abstraction; keeping the card token private inside the implementation is encapsulation. - 4
Explain polymorphism with an example. What is the difference between compile-time and runtime polymorphism?
Why ask it
Polymorphism is the pillar that drives extensible design.What to look for
Polymorphism lets code work with objects of different types through a common interface. Compile-time (static) polymorphism is method overloading, resolved by signature. Runtime (dynamic) polymorphism is method overriding, resolved by the object's actual type through dynamic dispatch. Example: a list of Shape objects where each subclass implements area(). - 5
What are the types of inheritance, and why do some languages not allow multiple inheritance of classes?
Why ask it
Tests knowledge of language design trade-offs.What to look for
Single, multilevel, hierarchical, multiple and hybrid. Multiple class inheritance raises the diamond problem: which parent's method wins. Java allows a class to extend one class but implement many interfaces; C++ allows multiple inheritance with virtual inheritance to manage diamonds; Python allows it and resolves methods with a defined method resolution order (MRO) that supports cooperative super() calls.
Before the Object-Oriented Programming interviews, see who can do the work
Cohesyve finds and contacts Object-Oriented Programming candidates from your job description and tests each one on an AI job simulation of the role, so these questions go to a ranked shortlist. 14-day free trial for 10 candidates, not charged until it ends.
Classes, Interfaces and Language Details
The details interviewers use to check hands-on experience.
- 6
What is the difference between an abstract class and an interface?
Why ask it
One of the most frequently asked OOP questions.What to look for
An abstract class can hold state, constructors and a mix of implemented and abstract methods, and a class extends only one in Java. An interface defines a contract that a class can implement alongside others. Since Java 8, interfaces can include default methods, added so libraries can extend interfaces without breaking existing implementations. Use an abstract class for shared base behaviour and state; use interfaces for capabilities that cut across hierarchies. - 7
What is the difference between method overloading and method overriding?
Why ask it
Checks precise vocabulary.What to look for
Overloading: same method name, different parameter lists, in the same class, chosen at compile time. Overriding: a subclass provides its own implementation of a method with the same signature as the parent, chosen at runtime. Mentions of the @Override annotation in Java, or that Python has no traditional overloading, show hands-on experience. - 8
What do access modifiers do? Compare public, private, protected and default (package-private) in Java.
Why ask it
Encapsulation in practice.What to look for
Public: accessible everywhere. Private: only inside the class. Protected: the class, subclasses and the same package. Default (no modifier): the same package only. Good candidates explain why fields are usually private with controlled accessors. - 9
What is the difference between composition and inheritance? Which do you prefer?
Why ask it
Shows design maturity.What to look for
Inheritance models an 'is-a' relationship and couples the subclass to the parent's implementation. Composition models 'has-a', building behaviour from contained objects, which is more flexible and easier to change. The common guidance is to favour composition over inheritance, using inheritance where a true substitutable 'is-a' relationship exists. - 10
What are static members, and when would you use them?
Why ask it
Tests understanding of class-level versus instance-level state.What to look for
Static fields and methods belong to the class, shared across all instances, and can be used without creating an object. Good uses: constants, factory methods, stateless utilities. Over-using static state makes code hard to test and can cause concurrency bugs.
Design Principles
Whether the candidate can turn OOP concepts into maintainable code.
- 11
What are the SOLID principles? Pick one and give a real example.
Why ask it
SOLID is the standard vocabulary for OOP design discussions.What to look for
Single responsibility, open/closed, Liskov substitution, interface segregation, dependency inversion. The example matters more than the list: for instance, splitting an Invoice class that calculates totals, prints PDFs and saves to a database into separate classes (single responsibility), or depending on a PaymentGateway interface instead of a concrete provider (dependency inversion). - 12
Explain the Liskov substitution principle. What is the square and rectangle problem?
Why ask it
The SOLID principle candidates find hardest to explain.What to look for
Objects of a subclass should be usable anywhere the parent is expected without breaking correctness. If Square extends Rectangle and setting the width also changes the height, code that sets width and height separately breaks. The fix is a different hierarchy or immutable shapes. Strong candidates connect this to inheritance being about behaviour, not just shared fields. - 13
What is coupling and cohesion? Which do you want more of?
Why ask it
Core vocabulary for evaluating design.What to look for
Aim for low coupling (classes depend on each other as little as possible, usually through interfaces) and high cohesion (each class has a focused purpose). Examples of refactoring a class that did too much show real experience. - 14
Name a design pattern you have used and explain the problem it solved.
Why ask it
Patterns are common follow-ups; real use beats a recited list.What to look for
Any well-known pattern (strategy, factory, observer, decorator, singleton, adapter) explained through a real problem: for example, a strategy pattern to swap pricing rules without if-else chains. Bonus for knowing the downsides, such as singletons hiding global state and complicating tests.
Applied Questions
Short modelling exercises that show how the candidate thinks in objects.
- 15
Design the classes for a parking lot system.
Why ask it
A standard low-level design exercise that tests modelling.What to look for
Identifying entities (ParkingLot, Level, Spot with types, Vehicle subtypes, Ticket, Payment), their relationships and responsibilities, and where polymorphism helps (spot size compatibility). Good candidates ask clarifying questions first and keep the design simple before extending it. - 16
When is object-oriented design the wrong fit?
Why ask it
Checks balanced judgement rather than dogma.What to look for
Simple scripts, data transformation pipelines and highly concurrent code can be cleaner in a functional or procedural style. Deep inheritance trees and classes that only hold data with no behaviour are warning signs. Strong candidates say they mix paradigms where the language supports it. - 17
How would you refactor a class with a long if-else chain that checks the object's type?
Why ask it
A practical test of polymorphism.What to look for
Replace conditionals with polymorphism: move each branch into a subclass or strategy that implements a common method, so new types are added without editing existing code (open/closed). Mentions of tests before refactoring are a good sign. - 18
What is the difference between shallow copy and deep copy of an object?
Why ask it
A common source of bugs with mutable objects.What to look for
A shallow copy duplicates the top-level object but shares references to nested objects, so changes to nested state show up in both. A deep copy recursively copies nested objects. Examples from Java (clone and copy constructors) or Python (copy.copy versus copy.deepcopy) show hands-on experience.
Running the interview well
- 1Ask for an example after every definition; reciting the four pillars is easy, applying them is not
- 2Use a short low-level design exercise to see how the candidate models objects and responsibilities
- 3Probe the abstract class versus interface answer in the language the team actually uses
- 4Ask when inheritance went wrong in their own code; experienced developers have a story
- 5Check that candidates can criticise OOP as well as describe it
- 6Keep the language-specific trivia light and focus on design reasoning
Common questions
What are the four pillars of OOP?
Encapsulation (bundling data and methods and protecting internal state), abstraction (exposing only what callers need), inheritance (a class reusing and extending another) and polymorphism (one interface, many implementations). Interviewers expect an example for each.
What are the most common OOPs interview questions?
Class versus object, the four pillars, abstract class versus interface, overloading versus overriding, composition versus inheritance, access modifiers, SOLID principles and a small design exercise such as a parking lot or library system.
Are OOPs interview questions the same in Java and Python?
The concepts are the same, but the details differ. Java enforces access modifiers and single class inheritance with interfaces; Python uses naming conventions for privacy, supports multiple inheritance with a method resolution order and relies on duck typing. Prepare in the language named in the job description.
How should freshers prepare for OOPs interview questions?
Learn each concept with a short code example you wrote yourself, practise explaining it out loud in two or three sentences, and build one small project (a library or inventory system) that uses classes, interfaces and inheritance so you can discuss real decisions.
Do I need to know design patterns for an OOP interview?
For junior roles, knowing a few common patterns such as factory, strategy and observer is usually enough. For mid-level and senior roles, expect to discuss patterns you have used, why, and their downsides.
What does OOPs stand for?
OOPs is commonly used to mean object-oriented programming system or simply object-oriented programming. OOP and OOPs refer to the same set of concepts in interviews.
Save these questions for the Object-Oriented Programming candidates who can do the work
Cohesyve takes your Object-Oriented Programming job description, finds candidates, reaches out to them and runs an AI job simulation of the real work, then returns a ranked shortlist.
1,500+
assessments completed
50%
faster time-to-hire
5 min
from JD to assessment
14-day free trial · 10 candidates · Not charged until the trial ends
Preparing for an Object-Oriented Programming interview yourself? Practise on an AI job simulation of the role. 3-day free trial, cancel anytime.
From the blog