1 | If you call a method in a class that was defined in some parent, the compiler has a simple algorithm to find the definition: it searches up the parent/child hierarchy. |
2 | Class: |
3 | method A |
4 | Definition of method |
5 | is given in parent |
6 | Class: |
7 | Class: |
8 | Class: |
9 | Class: |
10 | Object2 |
11 | Object1 |
12 | Object1 creates object2 |
13 | and calls object2.A |