OOPs4Humans

Abstraction

Hiding the complexity.

Abstraction

Analogy: car

Abstraction is like Driving a Car.

  • You use the Steering Wheel and Pedals (Interface).
  • You don't need to know how the combustion engine works (Implementation).

Abstraction hides the messy details and gives you a clean, simple interface.

Abstract Classes vs Interfaces

Abstract Class

A half-built blueprint. "I know this is a Vehicle, but I don't know how it moves yet."

Java Example
Switch language in Navbar
abstract class Vehicle {
    abstract void move(); // You must define this!
}

Interface

A contract. "I promise I can do these things."

Java Example
Switch language in Navbar
interface Flyable {
    void fly();
}
Up Next
Interfaces