| Introduction to OOP | Chapter 12: Implications of substitution: | next | previous | audio | real | text |
class Parent {
boolean equals (Object x) { ... }
}
class Child extends Parent {
boolean equals (Object x) { ... }
}
Parent p;
Child c;
if (p.equals(c)) // will execute using the parent method
if (c.equals(p)) // will execute using the childs method