Skip to content
Veltoryx Technologies
ProLesson 14.2Intermediate3 min readUpdated 30 October 2026

OOP and design interview questions

The object-oriented questions every Java interview includes, from the four pillars to equals and hashCode, with crisp answers.

Object-oriented questions appear in almost every Java interview, often as follow-ups like "give an example from your project". Answer each one with a definition, then a real example.

01The pillars

1. What are the four pillars of OOP?

  • Encapsulation: hide data, expose behaviour (private fields, validated methods).
  • Inheritance: reuse and extend a class (extends).
  • Polymorphism: one call, different behaviour (overriding and dynamic dispatch).
  • Abstraction: show what, hide how (interfaces, abstract classes). (4.1)

2. How do you achieve encapsulation in Java? Private fields, public methods that enforce rules, no setters that bypass those rules, and immutable classes where possible. (4.3)

3. Overloading vs overriding? Overloading: same name, different parameters, chosen at compile time. Overriding: a subclass redefines an inherited method with the same signature, chosen at run time from the object. (4.6)

4. Can you override a static or private method? No. Static methods are hidden, not overridden; private methods aren't visible to subclasses. (4.6)

5. Abstract class vs interface? An abstract class can have state, constructors and any methods, and a class extends only one. An interface defines a contract (default, static and private methods allowed, no instance state), and a class can implement many. Use an interface for a capability, an abstract class for shared code among related classes. (4.7)

6. Why doesn't Java support multiple inheritance of classes? To avoid the diamond problem. Interfaces allow multiple inheritance of type; conflicting default methods must be overridden explicitly. (4.5)

7. Composition vs inheritance? Inheritance is "is-a" (SavingsAccount is an Account); composition is "has-a" (a Car has an Engine). Favour composition: it's more flexible and less tightly coupled. (4.5)

Loading the rest of the lesson…