Abstract classes

Use the abstract modifier to define an abstract class—a class thatcan’t be instantiated. Abstract classes are useful for defininginterfaces, often with some implementation. If you want your abstractclass to appear to be instantiable, define a factoryconstructor.

Abstract classes often have abstract methods.Here’s an example of declaring an abstract class that has an abstractmethod:

  1. // This class is declared abstract and thus
  2. // can't be instantiated.
  3. abstract class AbstractContainer {
  4. // Define constructors, fields, methods...
  5. void updateChildren(); // Abstract method.
  6. }