Homework 2

Due Tue Sep 22, 5 points

For this assignment you only need to turn in answers for the questions that have a point count. Other questions should be given some thought and will be useful for review.

  1. (1 point) What are two kinds of inheritance?

  2. Do objects inherit from objects or do classes inherit from classes?

  3. What are untyped OOLs mainly used for? Why are typed OOLs often preferred?

  4. (1 point) What are two important aspects of encapsulation?

  5. How can delegation design patterns eliminate conditional statements (if..else and switch statements)?

  6. (1 points) What kind of methods are defined in the subject participant of the Observer design pattern?

  7. What do the terms push and pull mean in the context of the Observer design pattern?

  8. (1 point) Give an example of the Strategy design pattern. Identify each of the participants.

  9. Give three common kinds of object structures where a Composite design pattern is useful.

  10. (1 point) Suppose you have some kind of object structure, such as a parse tree, and you have implemented several ConcreteVisitor classes for it. Suppose that a new type of Concrete Element is added into the object structure. What further changes do you need to make?