OOP foundations
OOP interview questions
Practise explaining object-oriented design clearly, like you would in a real interview.
Categories
Showing 60 of 60
Mode
OOP foundations
How would you explain the difference between a class and an object?
OOP foundations
What roles do fields and methods play inside a class?
OOP foundations
What should a constructor be responsible for?
OOP foundations
Is a default constructor the same as a no-argument constructor?
OOP foundations
Why would you overload or chain constructors?
OOP foundations
What is stored when one object variable is assigned to another in Java?
Encapsulation and abstraction
What does encapsulation actually protect?
Encapsulation and abstraction
Why are getters and setters not automatically good encapsulation?
Encapsulation and abstraction
How do abstraction and encapsulation differ?
Encapsulation and abstraction
How do you decide whether a member should be public, protected, or private?
Encapsulation and abstraction
What is information hiding, and why does it matter?
Encapsulation and abstraction
How would you stop an object from entering an invalid state?
Inheritance and relationships
What problem is inheritance meant to solve?
Inheritance and relationships
How do is-a and has-a relationships influence your design?
Inheritance and relationships
Why is composition often preferred over inheritance?
Inheritance and relationships
What is the diamond problem in multiple inheritance?
Inheritance and relationships
Can you distinguish association, aggregation, and composition?
Inheritance and relationships
How does constructor chaining work between a superclass and subclass in modern Java?
Inheritance and relationships
What is the fragile base class problem?
Polymorphism and binding
What does polymorphism give us in practical code?
Polymorphism and binding
What is the difference between method overloading and method overriding?
Polymorphism and binding
What do static binding and dynamic binding mean?
Polymorphism and binding
A parent reference points to a child object. Which methods and fields are accessible?
Polymorphism and binding
Why is upcasting usually safe while downcasting can fail?
Polymorphism and binding
Which Java methods cannot participate in normal overriding?
Polymorphism and binding
What is a covariant return type?
Interfaces and abstract classes
When would you choose an abstract class instead of an interface?
Interfaces and abstract classes
Why can a Java class implement multiple interfaces but extend only one class?
Interfaces and abstract classes
Why can an abstract class have a constructor if it cannot be instantiated directly?
Interfaces and abstract classes
Why were default methods added to Java interfaces?
Interfaces and abstract classes
Why do we often depend on an interface rather than a concrete class?
Equality, copying, and immutability
What is the difference between object identity and logical equality?
Equality, copying, and immutability
Why must equals and hashCode agree in Java?
Equality, copying, and immutability
How would you distinguish a shallow copy from a deep copy?
Equality, copying, and immutability
Why is assigning an object reference not considered copying the object?
Equality, copying, and immutability
How would you design an immutable Java class?
Equality, copying, and immutability
What do we gain and lose by making objects immutable?
Object context and lifecycle
What is the difference between this and super in Java?
Object context and lifecycle
When should a member be static rather than instance-based?
Object context and lifecycle
Are static methods polymorphic in Java?
Object context and lifecycle
What stages does an object go through during its lifecycle?
Object context and lifecycle
Are Java objects always on the heap and local variables always on the stack?
SOLID and good design
What do low coupling and high cohesion look like in a design?
SOLID and good design
How do you interpret the Single Responsibility Principle?
SOLID and good design
What does the Open-Closed Principle mean in practice?
SOLID and good design
How can a subclass violate the Liskov Substitution Principle?
SOLID and good design
Why is one large interface often worse than several focused interfaces?
SOLID and good design
What is Dependency Inversion trying to achieve?
SOLID and good design
Can applying SOLID principles ever make a design worse?
Design patterns
When is a factory more useful than calling a constructor directly?
Design patterns
What problem does the Strategy pattern solve?
Design patterns
What trade-off comes with the Observer pattern?
Design patterns
Why is Singleton often criticized?
Practical design scenarios
How would you design a notification service that supports email, SMS, and push?
Practical design scenarios
A checkout must support several payment providers. How would you structure it?
Practical design scenarios
A class validates orders, stores them, charges customers, and sends emails. What would you change?
Practical design scenarios
Why can making Square inherit from Rectangle cause design problems?
Practical design scenarios
How would you model users, roles, and permissions without filling User with conditionals?
Practical design scenarios

