O'Reilly logo

Design Patterns Java™ Workbook by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introducing Interfaces (Chapter 2)

SOLUTION 2.1An abstract class with no nonabstract methods is similar to an interface in terms of its utility. However, note the following.
  • A class can implement any number of interfaces but can subclass at most one abstract class.

  • An abstract class can have nonabstract methods, which are usually instances of the TEMPLATE METHOD pattern. All the methods of an interface are abstract, whether or not this declaration is explicit.

  • An abstract class can declare instance variables that its subclasses inherit. An interface cannot declare instance variables, although it can establish static final fields.

  • An abstract class can define constructors; an interface cannot.

  • An abstract class's visibility can be public, protected ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required