Explain Encapsulation concept in OOP.Encapsulation is the process of hiding data of a class from objects. This is to say, if a function or a method inside this class is private, only objects of this class can access the method. The three access specifiers determine whether the methods are accessible to all classes or only the defining class or the friend class.Explain Encapsulation concept in OOP.Encapsulation is the process of binding / compartmentalizing the elements of an abstraction. It comprises of data and operations on data in a single unit. Encapsulation separates the conceptual interface and an abstraction.Explain Encapsulation concept in OOP.Encapsulation means keeping actions and attributes together under a single unit. This can also be understood using a motor bike example. A bike has actions such as 'switch on light', 'horn' etc. and attributes such specific color, size, weight etc. Here the actions and attributes are bundled together under a single unit, bike.
In a programming language, methods and properties that correspond to actions and attributes respectively are kept under a unit called object. The advantage of encapsulation is that the implementation is not accessible to the client. The user has to know only the functionality of encapsulated unit and information to be supplied to get the result.
|