COM1204, Summer 1998, Prof. Futrelle

Midterm Exam, sample questions

for exam on Thursday, August 20th

This includes sample questions numbered p1, p2, etc. The exam itself will include six questions, similar to these. "PS" refers to our phone system, "OO" to object-oriented.

1. What principles of design were satisfied by making the next_id slot static? What principles would be violated by not making it static? Hint: How would objects communicate changes to next_id as it was stepped?

2. In the class definition for System, what is the purpose of the following statement and give an example of its use:

3. Describe the purpose and operation of the following code. Also describe the strategy of using the function during the operation of the system.

4. What strategy did we use to access the "global" variable time without actually declaring a time global at top level?

5. In a member function of a certain class, the following two lines appear. Which one can be simplified, and how, and why?

6. How is it possible to create more than one constructor for a class? Why would this be useful? Answer the question by creating a very simple example, perhaps based on the phone system.

7. Why do you think that I chose to make all features of phone system classes public?

8. Why did Meyer discuss the representation of the point class both by a Cartesian coordinate form and its polar coordinate form? How does this relate to the concept of Abstract Data Type?

9. In the PS, when a speech message packet containing, for example, "Hello!" is created in the phone and placed on a wire, processed in the switch, placed on another wire and ends up in the other phone, how many copies of the packet are made? What principles of the object-oriented approach are illustrated by this sequence of events?

10. Why are we able to execute the run() function for both a phone and a switch? What principles of OO design does this illustrate?

11. We have separated the PS design documents from the code itself. What does Meyer have to say about such an approach?

12. A switch may have to exchange many packets with another switch in a single time step. Explain how this could be done by adding a slot to Packet of the form,

What additional methods might you need to add to Wire to support these multiple packet groups?

13. An alternate way for a phone and a switch to communicate would be to exchange their full state descriptions at each step. In what way might this violate Meyer's design rules?