O'Reilly logo

Design Patterns in Java™, Second Edition by William C. Wake, 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

B Solutions

Introducing Interfaces

Solution 2.1

(from page 12)

An 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; all the methods of an interface are effectively abstract.

•    An abstract class can declare and use fields; an interface cannot, although it can create static final constants.

•    An abstract class can have methods whose access is public, protected, private, or none (package). An interface’s methods are implicitly public.

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

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