Finishing the Static Model - Generalization, Specialization, and Inheritance - Polymorphism

4 important questions on Finishing the Static Model - Generalization, Specialization, and Inheritance - Polymorphism

An operation on a superclass will be inherited by its subclasses.
Not only will the argument list be inherited, but  if...?

if any method is supplied (the method is the implementation of the operation), it will also be inherited.

Even if the method is available on the superclass, it can be....?

Even if the method is available on the superclass, it can be overridden on the subclasses by simply supplying a method anywhere the default method is not sufficient.

If we looked at the code of FigureManager.getDiagramArea()  , what would we see?

If we looked at the code of FigureManager.getDiagramArea(), we would see something like:

totalArea = 0

loop over GeometricFigures in ordered set of Figure:GeometricFigures

get next GeometricFigure

totalArea = totalArea = GeometricFigure.getArea()

endLoop

return totalArea
  • Higher grades + faster learning
  • Never study anything twice
  • 100% sure, 100% understanding
Discover Study Smart

Why is polymorphism a big advantage?

Polymorphism is a big advantage for object-oriented development, as changes do not propagate, and testing the type of an object is often not needed.

It incorporates information hiding, i.e., the details of the getArea() operation are not exposed outside of the Circle or Square

The question on the page originate from the summary of the following study material:

  • A unique study and practice tool
  • Never study anything twice again
  • Get the grades you hope for
  • 100% sure, 100% understanding
Remember faster, study better. Scientifically proven.
Trustpilot Logo