OOPS Concepts in real life

oops

Sharing is caring!

Oops concepts in real life

Objects:

It is considered to be an instance of class.It contains real values instead of variables.In real life we can consider an mobile company which manufacture mulitple models as instance to mobile.so here mobile models where each one has its unique characteristics acts as a object.

Example:

so here in the above example mobile is a class and its models samsung and nokia which has their own characteristics acts as an object.

Classes:

It is considered to be an blueprint for the objects created.In other words it defines the methods and variables for particular object.

For Example here also we can consider mobile as a class in real life .Mobile has some values for its variables like profile type,IMEI number,processor etc and it has methods like dial,receive,reject,hold,send mms,etc.

Example:

As we said before here in this example mobile acts as a class and it has  methods such as getimeicode,sendmessage,dial,receive.

Abstraction:

It shows only the essential information rather than a very long description.

Consider an example where we are pressing on green color icon on our mobile to attend calls.But we are unaware of it inner functionality is what abstraction means that is it provides only relevant details to end user rather than irrelevant details.

Another example we can say is dialling a number shows a number on our display immediately but we doesn’t know what functionality it is performing inside.

Example:

 

Encapsulation:

Access rights provided to certain details of the class.In other words it provides access rights to details provided by abstraction.

Consider an real world example where our mobile has bluetooth which we activate to connect to other mobile near by .Suppose say if mobile A is connected to B  via bluetooth at the same time mobile C tries to connect to mobile A it will surely gets failed .This is due to accessibility restriction provided by Encapsulation.It is performed by three access specifiers which are namely public protected and private.

Example:

 

Polymorphism:

It is defined as the same operation which can be done by providing different inputs at different times.

Consider an example where nokia mobile has 5MP camera which has a functionality cameraclick .But if we like to take a click with panaromal mode here the concept of polymorphism is applied to make it effect where the functionality of camera click is same but mode differs.

It is an very good example for static or compile time polymorphism.It is also reffered as method overloading.

Another term dynamic polymorphism is one where functionality differs with the same method.

Consider an real scenario where we are sending an message from our mobile to a single person or group of persons.Here operation  sending message which is same for both the different functionalities.It is also termed as method overriding.

Sharing is caring!

Related posts: