Java
Java OOPs Concepts
Detailed notes on OOPs concepts with real-life examples.
18 pagesMay 24, 2025
The Four Pillars of OOP
- Encapsulation — bundling data and methods together
- Inheritance — reusing code across related classes
- Polymorphism — one interface, multiple implementations
- Abstraction — hiding complex implementation details
Example
class Animal {
void makeSound() {
System.out.println("Some generic sound");
}
}
class Dog extends Animal {
@Override
void makeSound() {
System.out.println("Bark!");
}
}