Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Joel's Three Questions

Is it a valid Object?

Will it compile?

What will get run?

When you construct each object you do something like this:
SimpleTurtle fred = new Turtle(myWorld);  //REMOVEDe 1

The first type (in this case SimpleTurtle) is called the 'static type' and the second type (in this case Turtle) is the 'dynamic type'. You don't need to memorize these terms (you may call them first/last types, left/right types, anything), but I will reference them in this description. Also when I use the term defined in the 'static type' or defined in a certain class then I mean written in the body of the code of that class.

Normally you call a method something like this:
fred.square(25); //REMOVEDe 2

So you need to ask your three questions. I'll run through them here, but I suggest you go over each one in detail using real examples. Opening up Dr. Java and writing simple classes to test would be a good idea.
1.) Is it a valid Object?
To answer this, you need to look at the constructor (REMOVEDe 1).
If any of these rules fail, then it will not compile and the error will be on REMOVEDe 1.

2.) Will it compile?
Now look at the actual method call (REMOVEDe 2).

3.) What will get run?

*These questions were first posed and answered by Joel Uthe. If a mistake is found then they may be altered, but only with the permission of the reigning Head TA, reigning Professor, and the majority of the TA staff. All credit should be given to Joel Uthe when teaching or discussing these rules.

Link to this Page