#1public class Classroom1 { private int roomNumber; public Classroom1(int aRoomNumber) { this.roomNumber = aRoomNumber; } public int getRoomNumber() { return roomNumber; }#2public void printOn(PrintStream report) { report.println("I am Classroom: " + getRoomNumber()); } }
#1public class Professor1 { private String name; public Professor1(String aName) { this.name = aName; } public String getName() { return name; }#2public void printOn(PrintStream report) { report.println("I am Professor: " + getName()); } }
public class College1 { private String name;#1private List<Object> list; public College1(String aName) { super(); this.name = aName; this.list = new ArrayList<>(); } public void add(Object o) { this.list.add(o); } public void printFullReport(PrintStream report) { /*Compile error, "printOn not understood by Object for (Object each: this.list)#2each.printOn(report); //<---------- compile error here */ report.println("College: " + this.name);#3report.println("Apologies, printing of list is not yet supported"); report.println("Objects do not understand \"printOn\""); } }