Object Oriented Programming With Real world Example

Kajasumanie Kanapathipillai
4 min readMar 26, 2018

https://iamkajas.blogspot.com/2023/12/object-oriented-programming-with-real.html

You are familiar with OOP concept theoretically but if interviewer ask to tell the concept with OOP concept then a lot of us are fail to answer.

Basically why we are write coding ,to solve our real world problem right.
In OOP a logic is right base on the object with this features
1.abstraction
2.encapsulation
3.inheritance
4.polymorphism
There are a lot of Car,bike,ATM and coffee machine.and there brands and name also different.
In OOP those are called object .

Objects logic are done by classes for example ,by phone we can call,Bluetooth ,take photo etc. those every logic
will be divide as classes.When we are creating class we need consider about SOLID principle.

Example for object and class

Abstraction
Before know about abstraction in OOP.We need to know what is the meaning of abstraction in English.
Abstraction means only show relevant data and details rest of others are hide.this is the most important pillar in OOP. This is mostly done by interfaces rather than abstract class.

Interface

Abstraction is done by classes or interface.

Abstract classes may have not implemented methods.

Abstract class

Abstract classes may have implemented methods.

We can generate tv by remote ,here remote is the interface between tv and man.

When interface and when abstract classes

So if you need multiple inheritance and a clear blueprint than has only the design and not the implementation; you go for interface. If you don’t need multiple inheritance but you need a mix of design plan and pre-implementation then abstract class is your choice.