Before we look at the abstract factory design pattern, let's first review the term abstract and how it applies to Java classes and the programs we develop.
The term abstract refers to something not having a definitive existence. In Java, abstract classes cannot be instantiated, but they can be inherited. Let's consider an example of an abstract Grandmother class that is extended by a Mother class. A third class, Daughter, is used to house the main() method. Here is the code for the Grandmother class:
abstract class Grandmother {
// Constructor
Grandmother() {
System.out.println("Grandmother constructor executed.");
}
}
Next, we have the Mother class, which extends Grandmother and has its own constructor method:
public class Mother extends Grandmother {
// Constructor
Mother() {
System...