Polymorphism, Exercises


Explain what the difference is between the concept of polymorphism and concept of dynamic binding. Why is polymorphism a pre request for dynamic binding?


Exercise 7.1 in the book. The topic is method redefinition in subclasses.


Exercise 7.6 in the book. The topic is inheritance and overwriting methods.


In an abstract class it is possible to have concrete methods, i.e., methods with a body (and naturally abstract methods). List the advantages and disadvantages of being able to have concrete methods in abstract classes.


Exercise 7.7 in the book. The topic is abstract classes.

Extra Assignments


Exercise 7.10. The topic is initialization order in inheritance hierarchies.


Create a class with two methods setup() and teardown(). Make an inheritance hierarchy that is three levels deep. In the derived classes implement the setup() method such that it is called in a general-to-specific order. Implement the teardown() method such that it is called in a specific-to-general order.