First you have to see that the actual object being created is an instance of class Extension. Thus, all invocations of the add() method will be resolved to the one in class Extension. When the object is constructed, add is invoked with argument 1 (i is now 2) first and then 2 (i is now 6). Then, add(8) is invoked, which changes i's value to 6+(2*8) = 22.
A little piece of friendly advice: If you found this code difficult to read, you might want to spend some time in the beginner forum since you may not have grasped the fundamentals of
polymorphism. That's just an advice, though
You might find the following story about polymorphism interesting:
How my Dog learned Polymorphism [ April 03, 2002: Message edited by: Valentin Crettaz ]