Object-Oriented_Programming_OOP_in_Java
Object-Oriented_Programming_OOP_in_Java
OOP is a programming paradigm based on the concept of "objects", which combine data and
behavior. Java was designed with OOP principles in mind and supports encapsulation, inheritance,
polymorphism, and abstraction.
Key Concepts:
- Classes and Objects: Classes define blueprints; objects are instances.
- Encapsulation: Bundling data and methods while restricting direct access.
- Inheritance: Creating new classes from existing ones to promote code reuse.
- Polymorphism: Allowing objects to be treated as instances of their parent class.
- Abstraction: Hiding complex details while exposing essential features.
Example:
--------------------------------
class Animal {
void sound() {
System.out.println("Animal makes a sound");
}
}