CHAPTER 53 — Interfaces

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

created: 3/6/99, revised: 5/7/99, 01/25/00, 01/26/02, 07/22/02, 06/05/03, 04/15/06

CHAPTER 53 — Interfaces

Java has single inheritance, only. This means that a child class inherits from only one parent class. Usually this is all you need. But sometimes multiple inheritance would be convenient. Interfaces give Java some of the advantages of multiple inheritance without the disadvantages.

Chapter Topics:

  • Interfaces
  • Defining an Interface
  • How a class implements an interface
  • Using an interface as a data type
  • Public interfaces
  • Implementing multiple interfaces
  • Extending an interface

The chapter includes some small examples, but you will have to wait until you start programming graphical user interfaces to see interfaces used realistically. Interfaces are crucial to GUI programming.

QUESTION 1:

Is your car a vehicle or a taxable property?