Quiz 7 -- Subclassing and numbers

Please write your name and lab section letter at the top of the page.

  1. Fill in the following table:
    The number...in base...equals the number...in base...
    1012510
    10102 10
    8710 2
    1100012 7
  2.  public class Animal {
        public String toString() { return "peep"; }
     }
    
     public class Dog extends Animal {
        public String toString() { return "arf"; }
     }
    
     public class Schnauzer extends Dog
        public String toString() { return "yap"; }
     }
    

    What is printed by the following?

       Animal yak = new Animal();
       Dog    dog = new Dog();
       Dog  bruno = new Schnauzer();
    
       Transcript.println("Yak says " + yak.toString());
       Transcript.println("Dog says " + dog.toString());
       Transcript.println("Bru says " + bruno.toString());