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

PreQuiz for 30March2005 Quiz

Pre-quiz3 Spring 2005

Consider the below UML class diagram:

Uploaded Image: Quiz3c.jpg

  1. Instances of which class(es) understand forward()?
  2. By what name do Deer know their corn fields?
  3. By what name does a Wolf know its simulation?
  4. Instances of which class(es) have a variable named heading?
  5. Instances of which class(es) know how to eat()?
  6. Instances of which class(es) have a variable named hunger?
  7. How many Deer might be in a given Simulation?
  8. How many Cornfields doe a Deer live in?
  9. What is a Wolf a specialization of?
  10. What are the subclasses of Turtle?

Answers? Questions? Questions on Answers? Comments on Questions?



Could someone check my answers and let me know if im right/wrong or even going in the right direction with this...
1. run() and die() of deer.......and eat() and die() of wolf
2. myField
3. mySim
4. Turtle
5. wolf
6. deer/wolf
7. unlimited
8. amount
9 Turtle
10. deer/wolf



I'm most confused about 4,5,6...any help would be much apperciated, thanks


Let's start with 1. run() and die() are not instances. Think of this question another way. Which CLASSES understand forward()? 5 and 6 are okay, but 4 is wrong. 8 is also wrong. Mark Guzdial

1. deer and wolf
4. deer and wolf?
8. 1 (is that from the "1" that's to the right of myField?)
i'm a bit confused on these as well...

Yes on 8. 1 and 4 are wrong yet. Mark Guzdial


1.) Do only turtles understand how to go forward? Or is it that turtles and deer and wolves understand forward()?

The latter. The superclass and all its subclasses know how to do whatever the superclass knows how to do – all the (protected and public) methods get shared. Mark Guzdial


1. Turtle, Wolf, Deer?
Yes

1) Turtle, Wolf, and Deer understand forward()
2) myField After a certain baseball movie, Bambi was forced to move from Lansing Road in Dyersville, Iowa
3) mySim , but Father Wolf lives near the Seeonee hills
4) Turtle, Wolf, and Deer
5) Wolf...The poor Deer are hungry too, but apparently they are too stupid to eat().
6) Deer, Wolf
7) no no, no no no no, no no...there's no limit
8) 1, unless his girlfriend doesn't know about his other girlfriend.
9) A Turtle. Joel REMOVEDdler Harris is confused.
10) Deer and Wolf

what's the difference between 7 and 8? i assumed you just use the 1 next to the arrows, but that's not right, is it? what differs and how?
The 1 means 1, the means 0 to any.

Did I miss the difference between the - and + in class?
Private vs. Public. Yes, we did discuss that in class.Mark Guzdial

The difference between 7 and 8 is that a Deer has ONE mySim and ONE myField, but there is no restriction as to how many actors a simulation has, correct?
Right.

Also, the + and - refer to the scope of the variable (i.e., private, public, protected)

Time to ace the quiz!



Links to this Page