Quiz 5 (Exercises from Chap. 10)

  1. Suppose that Which of the following assignments are legal given these declarations:
    Alligator alligator ;
    Canine wolf, dog ;
    Bovine cow, bull ;
    Carnivore carnivore ;
    Vegetarian vegetarian ;
    Mammal mammal ;
    
    1. wolf = new Canine() ;
    2. dog = new Carnivore() ;
    3. carnivore = new Carnivore() ;
    4. alligator = new Alligator() ;
    5. vegetarian = new Carnivore() ;
    6. carnivore = new Canine() ;
    7. carnivore = new Bovine() ;
    8. vegetarian = new Bovine() ;
    9. bull = new Canine() ;
    10. carnivore = vegetarian ;
    11. vegetarian = cow ;
    12. vegetarian = bull ;
    13. cow = bull ;
    14. bull = dog ;
    15. bull = (Vegetarian) dog ;
    16. cow = new Mammal() ;
    17. dog = new Mammal() ;
    18. dog = new Mammal() ;
    19. mammal = new Mammal() ;
    20. mammal = dog ;
    21. mammal = (Mammal) dog ;
    22. mammal = alligator ;
    23. mammal = (Mammal) alligator ;
    24. dog = (Mammal) cow ;
    25. cow = (Mammal) dog ;
  2. A Timer object is ticking, and with every tick it sends a message to an object of the following type: ________________________ .
  3. The message that a Timer object sends to its listener object is the following: _______________________________.
  4. Circle which of the following are objects (as opposed to messages):
  5. Connect the correct pairs.
    event                                    where it happened
    event listener                           the thing that reacts to the news
    event source                             the news or notification