Four pillars, one contract and the patterns everyone asks about. Encapsulation to polymorphism, the equals/hashCode contract, composition over inheritance, SOLID and the patterns Spring is built from.
Topics in this section
The four pillars
Think of a car. Encapsulation hides the engine under the bonnet. Abstraction hands you a steering wheel instead of a manual on combustion. Inheritance means an electric car is still a car. Polymorphism means you press “accelerate” and each car does it its own way.
Overloading vs overriding
Overloading is one restaurant with different menus for different party sizes — picked the moment you walk in (compile time). Overriding is a franchise branch changing the house recipe — which one you get depends on the branch you're actually in (runtime).
Interface vs abstract class
An interface is a job description: “must be able to drive”. You can meet many job descriptions at once. An abstract class is a half-built house: some rooms are finished, some are left for you — and you can only inherit one house.
The equals & hashCode contract
hashCode picks the drawer; equals checks the item inside it. If two equal objects land in different drawers, a HashMap searches the wrong drawer and swears your key isn't there.
Composition over inheritance
Inheritance says a SportsCar IS-A Car and welds it to the Car forever. Composition says a Car HAS-A Engine — swap in an electric one tomorrow without rebuilding the car.
SOLID principles
Five habits of code that's easy to change: every class has one job, you add features without editing old code, subtypes never surprise, interfaces stay small, and you depend on contracts, not concrete classes.
Each topic pairs a plain-language explanation with code, interview questions, and related practice where available.