Which of the following statements describe the Polymorphism principle of the GRASP approach to object-oriented design?
1.Superclass variables are typically exposed
2.A child class can be substituted for a parent class
3.An object can be used as if it were an object of its superclass while still using its overridden methods
4.A child class and a parent class have different types
5.Subclass-specific versions of a superclass method are implemented in the subclasses
6.Methods of the superclass can be used in the subclasses
7.Polymorphism is accomplished through inheritance and overriding
Answers
Answer:
An obejcr can be used as if it were an object of its super class while still using its overhidden methods
Answer:
The statements describe the Polymorphism principle of the GRASP approach to object-oriented design is
1. Superclass variables are typically exposed
4. A child class and a parent class have different types
5. Subclass-specific versions of a superclass method are implemented in the subclasses
6. Methods of the superclass can be used in the subclasses
7. Polymorphism is accomplished through inheritance and overriding.
Explanation:
According to the polymorphism principle, responsibility for defining the variation of behaviors based on type is assigned to the type for which this variation happens. This is achieved using polymorphic operations. The user of the type should use polymorphic operations instead of explicit branching based on type.
Problem: How to handle alternatives based on type? How to create pluggable software components?
Solution: When related alternatives or behaviors vary by type (class), assign responsibility for the behavior—using polymorphic operations—to the types for which the behavior varies. (Polymorphism has several related meanings. In this context, it means "giving the same name to services in different objects".)
#SPJ2