Lesson 13 of 36Article15 min
OOP Introduction
OOP organizes code around objects — bundles of data (fields) and behavior (methods). Java is built for OOP.
OOP — Object-Oriented Programming
OOP organizes code around objects — bundles of data (fields) and behavior (methods). Java is built for OOP.
Four pillars: Encapsulation, Inheritance, Polymorphism, Abstraction. You will learn each in this course.
Real-life example: A car object has data (color, speed) and behavior (accelerate, brake). You interact with the car, not raw engine wires.
- Encapsulation — hide details, expose safe methods
- Inheritance — reuse code from parent classes
- Polymorphism — one interface, many forms
- Abstraction — show only what matters
Why OOP matters in real projects
Large apps use classes to model users, orders, payments — each class owns its data and rules.
Teams work on different classes without breaking the whole system.
Real-life example: A school has Student, Teacher, Course classes — like departments in a company, each with clear duties.
Thinking in objects
// Instead of loose variables everywhere:
// String studentName; int studentMarks;
// Group related data in a class:
class Student {
String name;
int marks;
}