April 2019
Intermediate to advanced
360 pages
9h 17m
English
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 ...
Read now
Unlock full access