Thread
OOP Concepts are the Fundamentals of Programming Languages like Java, Python (and many others)

Here's a Dead Simple Guide to Understand It:
There are six different concepts in OOP:

1. Object
2. Class
3. Inheritance
4. Encapsulation
5. Abstraction
6. Polymorphism

Note: In this thread, we'll try to understand it from Java's standpoint.
1. Object

Every real-world entity is an object.

An object has Behaviour (things it does or performs) and Attributes (things that describe it).

For eg: A Chair object can have behaviour like Movement, Height Adjustment & Attributes like Color, Make & Model, and Price.
2. Class

The collection of all related objects is called a class.

Consider class as a general category which contains all the related objects inside it.

For eg: Objects like Wheelchair, Office Chair and Wooden Chair can be a part of the "Chair" class.
3. Inheritance

The way we inherited a few qualities from our parents similarly,
a class can also inherit the qualities from a parent class.

For eg: A Phone Class can have two Child Classes: 1) TelePhone
and 2) MobilePhone. Both can inherit the "calling" behaviour.
4. Encapsulation

It means wrapping data into a single unit & securing it.

For eg: Drug Capsule wraps different medicines into a single unit and protects them from the outside environment.

Bank Locker wraps your valuables into a single unit(locker) and protects it via passcode.
5. Abstraction

Hiding complexity from the user and showing only the relative stuff.

For Eg: In Car, all the complexity like the engine, machinery, etc is hidden from you; only relevant parts are shown, like the brakes, accelerator, and gearbox.
6. Polymorphism

It means many forms. With the same name, it provides different forms.

For eg: In Chess, we've 6 pieces - king, rook, bishop, queen, knight, and pawn. All of them "move" differently i.e. Bishop moves diagonally, Rooks move horizontally and vertically, etc.
All Chess piece performs a common behaviour "move" but they all do it differently.

The behaviour name "move" is the same but it's still differently done by different Objects.
That's a wrap!

I help people get started with Backend Development.

Follow me @vikasrajputin for more.

If you find this thread helpful then Like/Retweet the first tweet below:

Mentions
See All
  • Post
  • From Twitter
Great thread!