Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

A.java B.java C.java
D.java E.java F.java

  1. [13pts] Draw the class hierarchy for the above classes.
  2. [60pts] Assume we have the class definitions above, and that no other class is derived from any of the above classes. In the table below, each row is labeled with a declaration such that while you know the type of the reference x, you do not know the type of the object it points to, since I'm not showing you the definitions of the "mystery" functions. Each cell has an expression with a blank next to it. Fill in each blank with
    A x = mystery1(); x.cat() ______x.dog() ______x.dog(8) ______x.rat() ______x.pig() ______
    B x = mystery2(); x.cat() ______x.dog() ______x.dog(8) ______x.rat() ______x.pig() ______
    C x = mystery3(); x.cat() ______x.dog() ______x.dog(8) ______x.rat() ______x.pig() ______
    D x = mystery4(); x.cat() ______x.dog() ______x.dog(8) ______x.rat() ______x.pig() ______
    E x = mystery5(); x.cat() ______x.dog() ______x.dog(8) ______x.rat() ______x.pig() ______
    F x = mystery6(); x.cat() ______x.dog() ______x.dog(8) ______x.rat() ______x.pig() ______
  3. [27pts] Mark each of the below as "OK" or "Error".
    A var1 = mystery1(); B var2 = mystery2(); C var3 = mystery3(); D var4 = mystery4();
    
    var1 = var2; ___________        var2 = var1; __________     var1 = var3; __________
    
    
    var1 = var4; ___________        var2 = var4; __________     var3 = var4; __________
    
    
    var4 = var1; ___________        var4 = var2; __________     var4 = var3; __________