Interface Definition

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.

Answer:

No. An interface lists only constants and methods.

Interface Definition

An interface definition looks like this:

interface InterfaceName
{
  constant definitions

  method declarations (without implementations).
}

A method declaration is simply an access modifier, a return type, and a method signature followed by a semicolon.

This looks somewhat like a class definition. But no objects can be constructed from it. However, objects can be constructed from a class that implements an interface. A class implements an interface by doing this:

class SomeClass extends SomeParent implements interfaceName
{

}

A class always extends just one parent but may implement several interfaces.

QUESTION 3:

(Review: ) If a class definition omits extends SomeParent, what class does it extend?