Features of Object Oriented Programming
Object-Oriented Programming (OOP) is used to build OOPS. Objects are the basic building block of Object-Oriented Programming System (OOPS). The real world objects have two characteristics: state and behavior. For example, human beings have state, such as name, color, age, and height and behavior such as walking, dancing, and sleeping. All the objects in OOPS are based on real world having a specific state and behavior.
OOPS consists of the following features:
Encapsulation implies that the non-essential details of an object are hidden from the user and an access is provided to its essential details. Therefore, encapsulation is also called information hiding. For example, when you plug in the cord of a vacuum cleaner and switch it on, the vacuum cleaner starts functioning. An end-user need not know the working principle of a vacuum cleaner to convert electricity into suction power. The switch of th6 vacuum cleaner encapsulates the complex process of conversion of electricity into suction power. The complexity of an object is hidden as a result of encapsulation.
Computer games also use the feature of encapsulation. The user only needs to know how to play the game. However, the complex working of game is hidden from the user.
In object-oriented methodology, need of encapsulation arises because the emphasis is on designing classes in such a manner that the classes share data and methods among themselves. Encapsulation is the feature that provides security to the data and the methods of a class.
An Anytime money (ATM) that you use to withdraw money also has an encapsulated function. You insert an ATM card in the machine and provide the pin code. The only access that you have to the ATM is to provide the pin code for your account and not to the process of validating the password. If the pin code is correct, you can make the desired transaction. The...