DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 968,873 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Danish Saleem
Danish Saleem

Posted on • Originally published at buymeacoffee.com

OOP In Real Life!!

Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. An object can be defined as a data field that has unique attributes and behaviour.

OOP focuses on the objects that developers want to manipulate rather than the logic required to manipulate them. This programming approach is well-suited for programs that are large, complex and actively updated or maintained.
Four Pillars of Object-Oriented Programming are listed below:

1. Inheritance

The real-life example of inheritance is child and parents, all the properties of the father are inherited by his son. They have the same features but are not the same, they are identical.

father and son

2. Polymorphism

An example of Polymorphism can be visualized by the duties performed by a Man. Man is only one, but he takes multiple roles like – he is a dad to his child, he is an employee, a brother and many more. This is known as Polymorphism.

Man

3. Encapsulation

One of the real-world examples of encapsulation is Capsule, as capsule binds all its medicinal materials within it, similarly in java encapsulation units (class, interface, enums etc) enclosed all its data and behaviour within it.

Capsule

4. Abstraction

We all use an ATM for cash withdrawal, money transfer, retrieve min-statement, etc in our daily life. But we don’t know internally what things are happening inside ATM when you insert an ATM card for performing and kind of operations.

ATM


Did you find it helpful? Let me know your thoughts in the comments below!

Let's connect!

You can follow me on Twitter, LinkedIn & GitHub


If you like this post. Kindly support me by Buying Me a Coffee

Buy Me a Coffee

Top comments (1)

Collapse
 
saranjoel profile image
SaranJoel

It wolud be good, if includes with coding example.

🌚 Browsing with dark mode makes you a better developer by a factor of exactly 40.

It's a scientific fact.