CS 151 Lecture 14

Cover page image

Cay S. Horstmann

Lecture 14 Clicker Question 1

Consider the java.awt.Rectangle class and this subclass:

public class Square extends Rectangle
{
   public Square(int x, int y, int width)
   {
      super(x, y, width, width);
   }
}

What is true about this class?

  1. The constructor has a syntax error.
  2. The class doesn't compile because it has no instance fields or methods.
  3. It violates the law of Demeter.
  4. It violates the Liskov substitution principle.

Lecture 14 Clicker Question 2

What does the call

car.translate(x, y);

do in section 6.2 of the textbook?

  1. It moves the car when the mouse moves
  2. It moves the car to position (x, y)
  3. It moves the car by x horizontally and y vertically
  4. It translates to a foreign language

Lecture 14 Clicker Question 3

When I read through book sections before class that have a lot of code, I find that the best way to figure out what is going on is to

  1. Read the printed code listings in the book
  2. Look at the screen shots in the book
  3. Run the code and see for myself
  4. Read the book before class? What's with that?

Discussion