Chapter 5

Using Abstract Classes and Interfaces


check Understanding abstract methods and classes

check Using basic interfaces

check Using interfaces as types

check Adding constants to an interface

check Inheriting interfaces

check Working with callbacks

check Using default methods

In this chapter, you find out how to use two similar but subtly distinct features: abstract classes and interfaces. Both let you declare the signatures of the methods and fields that a class implements separately from the class itself. Abstract classes accomplish this by way of inheritance. Interfaces do it without using inheritance, but the effect is similar. This chapter also covers a feature called default methods, which are designed to make interfaces easier to work with.

Using Abstract Classes

Java lets you declare that a method ...

Get Java All-in-One For Dummies, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.