View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Summer 2001 Midterm Review

Wouldn't you like to be a pepper too?

A midterm in 2340 is 4-5 questions like each of the below. Most of the questions below are from actual midterms. I won't post answers, but I will correct any mistakes I notice. You guys must supply the raw material, and you'll get as much out of it as you put into it.


Historical Context

  1. Who first used the word "object-oriented" to talk about programming systems?
  2. Name a person or company who designed an OO language within the last 20 years.
  3. How did ideas in a drawing program influence OO development?
  4. Name another programming approach that was popular when OO was first developing, and name a language of the time that exemplified it.

Put your answers/comment/questions at Sum2001 Midterm Review: Historical Context

Changed/Update mechanism


In the third Clock user interface, a Clock instance forms the model and a ClockText instance forms part of the user interface. Describe the sequence of messages that occur when a second of time passes by, such that the Clock is updated and the updated time is displayed by the ClockText.

Put your answers/comments/questions at Sum2001 Midterm Review: Changed/Update


OO Theory

  1. What is a class? What is an instance?
  2. What is the difference between a class and instance method?
  3. What is the difference between a class and instance variable?

Put your answers/comments/questions at Sum2001 Midterm Review: OO Theory

Design Critique


A friend is designing a problem for his job, and they have asked you to critique it. What's going wrong in each of the following situations?


  1. "Here are my CRC cards. This class here is named MapLinkedList and it is a collection of all the Map objects in the system..."
  2. "Here is my object ProcessMap. It knows its Map and it does the basic processing needed to get it on my website..."
  3. "But everything is controlled here by the MapManager object. No other object processes without confirming it with the MapManager."

Put your answers/comments/questions at Sum2001 Midterm Review: Design Critique


Hotel Doors OOA/D

You have been hired to design a door lock and tracking system for a hotel. These are doors that are opened with a key card that contains an encoded number of some sort. NOTE: The keys have no processor nor network connection. You can't "talk to" a key.


  1. Name at least two classes that you would need in the design for this system, and two classes that you might consider but would reject. Give your reasons for rejecting those two classes.
  2. On the back of this sheet or on a separate sheet that you attach to the exam (remember, each problem will be graded separately!), draw the CRC cards for this scenario:
A customer gets a card key, takes it to the door, puts it in the door lock which checks if it's valid, then the door opens because it is valid.


Put your answers/comments/questions at Sum2001 Midterm Review: Hotel Doors OOA/D

Write Smalltalk Code



Write workspace code (something I can select and say DoIt in the workspace) to draw the below figure. Don't worry about exact sizes–just draw two rectangles with the text inside. (To remind you, Pens know how to up, down, go:, turn:, and north:. Strings know how to displayAt: a given point.)

Uploaded Image: cs2340.gif

Put your answers/comments/questions at Sum2001 Midterm Review: Write Smalltalk Code

UML Class Diagramming



Draw a UML class diagram for the set of classes described below.

Put your answers/comments/questions at Sum2001 Midterm Review: UML Class Diagramming

Analyze Student/Classroom Code


Imagine that I have a Student object in a Classroom object, something like this.

| s c |
c := Classroom new name: 'CS2390'.
s := Student new name: 'Fred'; section: 'a'; number: '123456789'.
c addStudent: s.
s := Student new name: 'Wilma'; section: 'b'; number: '3456789012'.
c addStudent: s.
s := Student new name: 'Barney'; section: 'a'; number: '012345678'.
"...More code here..." 


a. (7 points) What would you say is the relationship between Student objects and the Classroom object is? Why?

b. (10 points) What attributes and services do you think that the Student and Classroom objects have, based on what you see in the above code?

Put your answers/comments/questions at Sum2001 Midterm Review: Analyze Student/Classroom Code

Reading Code

| anArray aString |
anArray := #('abc' 'def' 'ghi','jkl').
aString := ''.
anArray do: [:each |
aString := aString, each.].
Transcript show: aString.



| i test |
i := 1.
test := (i < 10).
[test] whileTrue: [Transcript show: 'hello'.
i := i + 1.].


Put your answers/comments/questions at Sum2001 Midterm Review: Reading Code


Simulate a Motorcycle


Imagine an object-oriented simulation of a motorcycle.

  1. What instance variables are you going to need for each of the key, engine, and wheel classes?
  2. Write the methods insert for key; start and run for engine; and turn for the wheel.
  3. Write whatever accessor methods you need to make the above example work.
  4. Write the workspace code that you'd use to create the above scenario

Put your answers/comments/questions at Sum2001 Midterm Review: Simulate a Motorcycle



More Drawing in Smalltalk


  1. Using Pen, write the code to draw an equilateral triangle.
  2. Using the Box class, write the code to draw a pyramid of three boxes.
  3. Explain what this code will do:
| joe |
joe := Box new.
30 timesRepeat: [joe turn: 12.]


Put your answers/comments/questions at Sum2001 Midterm Review: More Drawing in Smalltalk

Analyze Robot Car


A robot is being designed to explore the surface of Mars autonomously.

External Image

Features of this robot include:

You are being asked to write some of the operating software for this robot.

Create a class diagram for the robot. (You don't have to add more than what's in the above example.) In your analysis, be sure to address:

Put your answers/comments/questions at Sum2001 Midterm Review: Analyzing the Robot Car

Links to this Page