go to previous page   go to home page   go to next page

Answer:

No. An interface inclues only constants and method headers.


Interface Definition

An interface looks like this:


interface InterfaceName
{
  constant definitions

  method headers (without implementations).
}

A method header is an access modifier, a return type, the method name, a parameter list followed by a semicolon.

The methods in an interface are public by default, so that modifier may be left out. The methods cannot be private and cannot be protected.

An interface looks somewhat like a class definition. But no objects can be constructed from it. However, you can define a class that implements an interface, and once you have done that you can construct objects of that class.

A class implements an interface by doing this:


class SomeClass extends SomeParent implements interfaceName
{

}

A class extends just one parent, but may implement several inferfaces.


QUESTION 3:

How does a class implement more than one interface?