HELP! * GREY=local LOCAL HTML version of Foils prepared July 10 1996

Foil 88 Further Features of Interfaces

From Basic Lectures on Java Language Applets Graphics Networking Trip to China and Icase Tutorial -- July 12-28 and June 10-13 96. by Geoffrey C. Fox * Important Information in IMAGE

Interfaces are either public or have the default friendly access (public for the package and private elsewhere)
Methods in an interface are always abstract and have the same access as the interface. No other modifiers may be applied
Variables in an interface are public, static, and final. They must be initialized.
When a class implements an interface:
  • it implements all the methods described in the interface
  • or it is an abstract class, which leaves the implementation of some or all of the interface methods to its subclasses
Interfaces can incorporate one or more other interfaces, using the extends keyword:
  • public interface DoesItAll extends Storable, Paintable {
    • public void doesSomethingElse();
  • }
A class can implement more than one interface:
  • public class Picture implements Storable, Paintable {
    • public void store(Stream s) {...}
    • public void retrieve(Stream s) {...}
    • public void refresh() {...}
  • }



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Feb 18 1997