/* This is our Person superclass. */ public class Person { String name; String occupation; int age; Person(String n, String o, int a) { name = n; occupation = o; age = a; } public boolean equals(Person p) { if(name.equals(p.name)) { return true; } else { return false; } } } /* This is our Student subclass. */ public class Student extends Person { String major; Student(String n, String o, int a, String m) { super(n, o, a); major = m; } public boolean equals(Student s) { if(name.equals(s.name)) { return true; } else { return false; } } } /* In this case of polymorphism, the equals method of both classes is overloaded i.e. while it takes different objects as parameters in each class, the function of the method remains the same. */