CS 151 Lecture 15

Cover page image

Cay S. Horstmann

Lecture 15 Clicker Question 1

The GeneralPath class path implements the Shape interface. You can add shapes to a GeneralPath. This is an example of which design pattern?

  1. Observer
  2. Iterator
  3. Composite
  4. Decorator

Lecture 15 Clicker Question 2

The Rectangle2D.contains method calls the getX, getY, getWidth, and getHeight methods instead of looking up the x, y, width, and height instance variables. This is an example of which design pattern?

  1. Observer
  2. Strategy
  3. Template Method
  4. Decorator

Lecture 15 Clicker Question 3

Consider a class with a method

public class SomeClass
{
   public void read(InputStream in) throws IOException
}

Which of the following statements is true about overriding this method in a subclass?

  1. The subclass method must be declared as throws IOException
  2. The subclass method must be declared as throws IOException or a subclass of IOException
  3. The subclass method must be declared as throws IOException or a superclass of IOException
  4. None of the above

Lab

Do problem 17 from your text book with a buddy.

Discussion