The Template Method Pattern defines the skeleton of an algorithm in a method, deferring some steps to subclasses.  The Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.  This pattern is all about creating a template for an algorithm.  The template is a method that defines an algorithm as a set of steps.  One or more of these steps is defined to be abstract and implemented by a subclass.

The Hook!  A Hook is a method that is declared in the abstract class, but only given an empty or default implementation.  This gives subclasses the ability to "hook" into the algorithm at various points, if they wish; a subclass is also free to ignore the hook.

An example of the Template Method Design Pattern follows:

public abstract class CaffeineBeverage {
	void final prepareRecipe() {
		boilWater();
		brew();
		pourInCup();
		addCondiments();
	}
	
	abstract brew();  //  Template Method
	abstract addCondiments();  //  Template Method
	void boilWater() { ... Implemented... }
	void pourInCup() { ... Implemented... }
}

public class Coffee extends CaffeineBeverage {
	void brew() { ... Implemented Here... }
	void addCondiments() { ... Implemented Here... }
}

public interface Tea extends CaffeineBeverage {
	void brew() { ... Implemented Here... }
	void addCondiments() { ... Implemented Here... }
}

//  Template Method with hook:
public abstract class CaffeineBeverage {
	void final prepareRecipe() {
		boilWater();
		brew();
		pourInCup();
		if (customerWantsCondiments()) {
			addCondiments();
		}
	}
	abstract void brew();
	abstract void addCondiments();
	void boilWater() { ... }
	void pourInCup() { ... }
	boolean customerWantsCondiments() { return true; } //  Hook
}
public class Coffee extends CaffeineBeverage {
	void brew() { ... }
	void addCondiments() { ... }
	@Override boolean customerWantsCondiments() {
		//  Query customer
		return result;
	}
}