Shweta,
This a great example and I learned something from it. What's happening here is , as per the Template Method
Pattern, the Base.class (superclass) is letting the Derived.class (subclass) redefine the certain steps in the algorithm. In other words, the Derived.class (subclass) is providing the implementation of the addValue() method.
If you remove the addValue() method from the Derived.class the superclass will use its own implementation of addValue() as expected.
The superclass does not need to know about the subclass, the dependency, like you said, is unidirectional. Its like parent teaching the kid how to do somthing, and kid mostly follows all the steps later, but few of the steps the kid does its own way. Only at runtime, the superclass lets the subclass follow steps "in its own way." Not the best analogy, but it helps me.
Thanks for the Post!
Sumit