Introduction to OOP Chapter 17: The Polymorphic Variable : next previous audio real text

Example, Repainting Window

class Window {
	public void repaint () {
			// invoke the deferred method paint.
			// Because the implicit receiver, this,
			// is polymorphic, the method from the
			// child class will be executed
		paint (graphicsContext);

	abstract public void paint (Graphics g); // deferred

	private Graphics graphicsContext;

class GraphicsWindow extends Window {
	public void paint (Graphics g) {
		// do the appropriate painting job
Only the child class knows how to paint the window. The receiver variable is responsible for remembering the actual class of the receiver when executing the method in the parent class.
Intro OOP, Chapter 17, Slide 05