Polymorphism, continued
int id; // Id number of room
{ return ”Room: ” + id; }
class Bathroom extends Room
{ return ”Bathroom: ” + id; }
/* Client code. The class of the object, not the type of the variable, determines which method is invoked. */
System.out.println(r1); // output: “Room: …”
Room r2 = new Bathroom();
System.out.println(r2); // output: “Bathroom: …”