CS 151 Lecture 14

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?
- The constructor has a syntax error.
- The class doesn't compile because it has no instance fields or methods.
- It violates the law of Demeter.
- 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?
- It moves the car when the mouse moves
- It moves the car to position (x, y)
- It moves the car by x horizontally and y vertically
- 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
- Read the printed code listings in the book
- Look at the screen shots in the book
- Run the code and see for myself
- Read the book before class? What's with that?
Discussion
