Basic concepts of oop

in oop •  4 years ago 

There are 4 basic concepts in Object-Oriented Programming(OOP) :

1.Inheritance => Here, the object acquires or shows all the properties and behaviors of the parent Object. So, it will be easy to reuse code as well as it will be easy to understand the principle. For example just thing of it as a human you will be resembling the features physically and logically like your parents. That's how this works.

2.Encapsulation => This one is actually binding up codes and data together, that is binding up methods/functions with data(variables) together. Consider it like a capsule in which medicine are mixed together where we can't see anything. This is like protecting the function happening in back from the site of the user.

3.Abstraction => This is what doing that hiding thing like I mentioned earlier. So user can't find how the function is working. and this distinguishes between different objects. It classifies objects into concepts and focuses on common properties.

4.Polymorphism => Here, one functions/task is performed in different ways. For example, When we take a shape class with data of radius, length, and width; we can find the area of rectangle, circle and square with different functions.

In Object Oriented Programming, properties are also called as attributes, and data members. These are actually the variables we create.
And functions are called as methods, behaviors and member functions.
The properties are said to be private while methods are public. So the assigned value of properties/instance variables can be used in programs without showing them.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!