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).
- What does this print? ____________________________________
hp = new HandyPerson("Jill"); System.out.println(hp);
- What does this print? ____________________________________
hu = new HandyPerson("Mike"); // Assign HandyPerson to Human System.out.println(hu);
- What does this print? ____________________________________
hp = new Human("Betty"); // Human to HandyPerson System.out.println(hp);
- What does this print? ____________________________________
hu = new HandyPerson("Chris"); System.out.println(hu.changeBulb()); // ChangeBulb
- What does this print? ____________________________________
hu = new NobodySpecial("Tom"); // Assign NobodySpecial to Human System.out.println(hu);
- What does this print? ____________________________________
hp = new NobodySpecial("Bill"); // Assign NobodySpecial to HandyPerson System.out.println(hp);
- What does this print? ____________________________________
ns = new HandyPerson("Sally"); // Assign HandyPerson to NobodySpecial System.out.println(ns);
- What does this print? ____________________________________
pl = new Plumber("Andrew"); // Plumber System.out.println(pl);
- What does this print? ____________________________________
pl = new HandyPerson("Nancy"); // HandyPerson to Plumber hp = (HandyPerson)pl; System.out.println(hp);
- What does this print? ____________________________________
ob = new HandyPerson("Ralf"); // HandyPerson to Object System.out.println(ob);