answersLogoWhite

0

What is specialization & generalization? Explain how generalization is different from specialization

Specialization is a property of inheritance used for creating specialized attributes, methods that only apply to objects of that class. Specialized classes are subclasses placed below super classes. Generalization is the process of extracting shared characteristics from two or more classes, and combining them into a generalized superclass.

Shared characteristics can be attributes, associations, or methods. Generalized classes are generally parent classes of specialized classes. In other words generalization is bottom up approach whereas specialization is Top to bottom approach

Example:

In Figure , the classes car and scooter partially share the same attributes. From a domain perspective, the two classes are also very similar. During generalization, the shared characteristics are combined and used to create a new superclass vehicle. car and scooter become subclasses of the class vehicle.

Similarly, the class vehicle has the a special attribute, which is needed only for car, but not for scooter. Additionally there is a special attribute, which is needed only for scooter Obviously, here two similar but different domain concepts are combined into one class. Through specialization the two special cases vehicles are formed The epecial attribute is placed where it belongs-in car /scooter.

User Avatar

Wiki User

12y ago

What else can I help you with?