Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

public boolean equals(Student otherStudent) { return this.hasSameName(otherStude

ID: 3919156 • Letter: P

Question

public boolean equals(Student otherStudent)
    {
        return this.hasSameName(otherStudent) &&
              (this.studentNumber == otherStudent.studentNumber);
    }

In class Student, method equals() , why a reference to Object is passed as a parameter instead of a reference to Student? Note that class Object also has a method equals() that has as a parameter a reference to Object.

1. Both a and b

To allow the method to be overloaded in derived classes for polymorphic purposes

3. To allow the method to be overridden in derived classes for polymorphic purposes

4. None listed

1. Both a and b

2.

To allow the method to be overloaded in derived classes for polymorphic purposes

3. To allow the method to be overridden in derived classes for polymorphic purposes

4. None listed

Explanation / Answer

The reason for the above is to allow the method to be overridden in derived classes for polymorphic purposes.

The correct option is 3