Graphic by Keith Ohlfs

CS111, Wellesley College, Fall 1997

Prelab #5
[CS111 Home Page] [Syllabus] [Students] [Lecture Notes] [Assignments] [Programs] [Documentation] [Software Installation] [FAQ] [CS Dept.] [CWIS]

CS111 Prelab #5: Execution Model

Due Date: Beginning of lab, October 6 or 7.

In lecture, you saw how the Java Execution Model works. For each method that is invoked, you can draw a picture, or "frame", of what that method does. This frame includes boxes for writing in the values of variables and a list of the statements carried out by that method. Each of those methods in turn may have an execution frame drawn for it. For a given java program in which each method invokes several other methods in turn, the result is an "Execution Tree" that shows the frames for each of the methods in the program. For a more detailed description, and for an example of what an Execution tree looks like, see the notes on the Java Execution Model, which can be accessed from the Lecture Notes page of CS111 (This will be linked by the end of the day, Thursday, October 2).

Drawing an execution frame for a java program

1. Download the folder, "diamond", from the CS111 download folder.

2. View the applet with AppletViewer, by opening diamond.html.

3. Look at the diamond.java file to see the source code.

4. Draw (on paper by hand or by computer, whichever is easiest for you) a picture of the final Execution Tree for this program. Use the format shown in the Java Execution model notes.

Start by drawing the execution frame for the Paint method. Then show the execution frame for the drawDiamond method. The drawDiamond method invokes two more methods that you should draw frames for. Repeat this process until you have the entire tree drawn. You do not have to draw frames for the g.setColor, g.fillRect, or g.drawLine methods. We will consider these to be our primitives. You should draw frames for each invocation of each method. If a method is invoked twice, you should show two frames, each positioned at the appropriate location in the tree.

Turning in Prelab 5

You will actually turn in a piece of paper with the execution tree drawn on it. Make sure you put your name on the paper! Hand it in at the beginning of lab.