Java: HandyPerson Interface Exercises - 1

Name ________________________________________

The following questions should be answered in referring to HandyPerson Example .

What is printed by the following?

If it is erroneous, write C for syntax (compilation) error or R for runtime error (ie, it crashes).

  1. What does this print? ____________________________________
        hp = new HandyPerson("Jill");
        System.out.println(hp);
        
  2. What does this print? ____________________________________
        hu = new HandyPerson("Mike");    // Assign HandyPerson to Human
        System.out.println(hu);
        
  3. What does this print? ____________________________________
        hp = new Human("Betty");         // Human to HandyPerson
        System.out.println(hp);
        
  4. What does this print? ____________________________________
        hu = new HandyPerson("Chris");  
        System.out.println(hu.changeBulb()); // ChangeBulb
        
  5. What does this print? ____________________________________
        hu = new NobodySpecial("Tom");   // Assign NobodySpecial to Human
        System.out.println(hu);
        
  6. What does this print? ____________________________________
        hp = new NobodySpecial("Bill");   // Assign NobodySpecial to HandyPerson
        System.out.println(hp);
        
  7. What does this print? ____________________________________
        ns = new HandyPerson("Sally");   // Assign HandyPerson to NobodySpecial
        System.out.println(ns);
        
  8. What does this print? ____________________________________
        pl = new Plumber("Andrew");      // Plumber
        System.out.println(pl);
        
  9. What does this print? ____________________________________
        pl = new HandyPerson("Nancy");   // HandyPerson to Plumber
        hp = (HandyPerson)pl;
        System.out.println(hp);
        
  10. What does this print? ____________________________________
        ob = new HandyPerson("Ralf");   // HandyPerson to Object
        System.out.println(ob);