9
C H A P T E R
Interfaces
My apple trees will never get across
And eat the cones under his pines, I tell him.
He only says  Good Fences Make Good Neighbors. 
 Robert Frost,
Mending Wall
 (1914)
A
N interface declaration introduces a new reference type whose members are
constants and abstract methods. This type has no implementation, but otherwise
unrelated classes can implement it by providing implementations for its abstract
methods.
Java programs can use interfaces to make it unnecessary for related classes to
share a common abstract superclass or to add methods to
Object
.
An interface may be declared to be an
direct extension
of one or more other
interfaces, meaning that it implicitly specifies all the abstract methods and con 
stants of the interfaces it extends, except for any constants that it may hide.
A class may be declared to
directly implement
 one or more interfaces, mean 
ing that any instance of the class implements all the abstract methods specified by
the interface or interfaces. A class necessarily implements all the interfaces that its
direct superclasses and direct superinterfaces do. This (multiple) interface inherit 
ance allows objects to support (multiple) common behaviors without sharing any
implementation.
A variable whose declared type is an interface type may have as its value a
reference to any object that is an instance of a class declared to implement the
specified interface. It is not sufficient that the class happen to implement all the
abstract methods of the interface; the class or one of its superclasses must actually
be declared to implement the interface, or else the class is not considered to imple 
ment the interface.
183






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Inexpensive Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Jsp Hosting Cheap Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved