Object-Oriented Programming
Java is built on four OOP pillars — encapsulation, inheritance, polymorphism, and abstraction. Understanding these well is not just required for interviews; it directly determines whether the code you write is maintainable, testable, and extensible. Modern Java (16+) adds records and sealed classes that reshape how you model data.
Note: Clarifications — this domain includes JDK-specific features (records, sealed classes). Each topic indicates required JDK version when relevant; check the linked JEPs and language docs before using a feature in production.
What You'll Find Here
| Topic | Description |
|---|---|
| Classes & Objects | Blueprints vs. instances — fields, methods, constructors, this. |
| Encapsulation | Access modifiers, getters/setters, immutable classes. |
| Inheritance | extends, method overriding, super, Liskov Substitution Principle. |
| Polymorphism | Compile-time (overloading) vs. runtime (overriding) dispatch. |
| Abstraction | Abstract classes vs. interfaces; when to use each. |
| Records (Java 16+) | Concise immutable data carriers; compact constructors. |
| Sealed Classes (Java 17+) | Restricted hierarchies enabling exhaustive switch. |
Learning Path
- Classes & Objects — understand the class/instance relationship and object construction.
- Encapsulation — learn to hide state and expose intent through controlled access.
- Inheritance — study when to extend vs. compose; the classic mistake is over-inheriting.
- Polymorphism — this is the concept most interviews probe with tricky overloading/overriding questions.
- Abstraction — distinguish abstract classes from interfaces; learn when
defaultmethods change the decision. - Records (Java 16+) and Sealed Classes (Java 17+) — Java 17+ additions every modern Java developer needs.
Related Domains
- Core Java — language primitives and control flow that OOP builds on.
- Java Type System — generics and type bounds are used throughout OOP hierarchies.
- Java Design Patterns — GoF patterns are OOP in action.