Title: Interface declaration
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: (OLDstyle) Learning Modules

Interface declaration

An interface is declared with the following:

Optional modifier public or package-private (no modifier).

The keyword interface.

The interface name.

Optional keyword extends followed by one or more interfaces.

The interface body consisting of one or more fields and methods, enclosed by curly braces.

Interface syntax:

[<access-modifier>] interface < interface-name> [extends <interface-list>]
{
< interface-body>
}

Where:
<access-modifier> is one of ‘public’ or blank.

<interface-body> is any combination of the following:
<field-declarations>
<method-declarations>

For more information, see:

Defining an interface