![]() ![]() ![]() For example, A person at the same time can have different characteristics. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form. The word polymorphism means having many forms. Inheritance allows the user to reuse the code whenever possible and reduce its redundancy. So when we create a class, we do not need to write all the properties and functions again and again, as these can be inherited from another class that possesses it. When we write a class, we inherit properties from other classes. ![]() The capability of a class to derive properties and characteristics from another class is called Inheritance. Inheritance is an important pillar of OOP(Object-Oriented Programming). Here the data of the sales section and the employees that can manipulate them are wrapped under a single name “sales section”. He will first have to contact some other officer in the sales section and then request him to give the particular data. In this case, he is not allowed to directly access the data of the sales section. Now there may arise a situation when for some reason an official from the finance section needs all the data about sales in a particular month. Similarly, the sales section handles all the sales-related activities and keeps records of all the sales. The finance section handles all the financial transactions and keeps records of all the data related to finance. Ĭonsider a real-life example of encapsulation, in a company, there are different sections like the accounts section, finance section, sales section, etc. As in encapsulation, the data in a class is hidden from other classes, so it is also known as data-hiding. In Encapsulation, the variables or data of a class are hidden from any other class and can be accessed only through any member function of their class in which they are declared. It is the mechanism that binds together code and the data it manipulates. This is what abstraction is.Įncapsulation is defined as the wrapping up of data under a single unit. The man only knows that pressing the accelerators will increase the speed of the car or applying brakes will stop the car, but he does not know about how on pressing the accelerator the speed is increasing, he does not know about the inner mechanism of the car or the implementation of the accelerator, brakes, etc in the car. Consider a real-life example of a man driving a car. Data abstraction refers to providing only essential information about the data to the outside world, hiding the background details or implementation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |