Professional Documents
Culture Documents
The Characteristics of OOP:: Polymorphism, Inheritance and Aggregation
The Characteristics of OOP:: Polymorphism, Inheritance and Aggregation
The Characteristics of OOP:: Polymorphism, Inheritance and Aggregation
Encapsulation: Encapsulation is the process in which no direct access is granted to the data; instead, it is hidden. If you want to gain access to the data, you have to interact with the object responsible for the data. For example if you want view or update employee information, you would have to work with Emp object. Difference between Abstraction and Encapsulation is, Abstraction is a technique that helps to identify which specific information should be visible and which information should be hidden and Encapsulation is the technique for packaging the information in such a way as to hide what should be hidden, and make visible what is intended to be visible. Polymorphism: Polymorphism is the ability of two different objects to respond to the same request message in their own unique way. You can implement polymorphism concept through overloading. You can implement different methods of an object which has same name but change in number of arguments and type of arguments passing. For example you have the employee class which has two methods with the same name empProfile, but one method takes empId as argument another method takes empId and role as arguments. In this situation you pass only empId, then it will call first method which takes only one argument as parameter and if you pass both empId and role, it will call second method which takes two arguments.
Inheritance: Inheritance is concept of clarify objects in your programs according to common characteristics and function. In other words grouping all common characteristics in one class and all other class has to implement this class to work with those characteristics. For example, you can define Employee class which has common properties name, idetc for all employees and managers. Manager class has to inherit this Employee class to define general properties
and it may have its own properties also like number of employees under him. So, whenever there is a change for Employee class, it will reflect on Manager class also.
Aggregation: Aggregation is when an object consists of a composite of other objects that work together. For example, your Car object is a composite of the wheel objects, the engine object and so on. In fact, the engine object is a composite of many other objects. There are many examples of aggregation in the world around us. The ability to use aggregation in OOP is a powerful feature that enables you to accurately model and implement business processes in your programs.