Basic HTML version of Foils prepared 9 Sept 1997

Foil 41 Further Features of Interfaces

From Java to be used in (Scientific) Computing Part II: Java Language and Object-Oriented Concepts Basic Simulation Track for Computational Science CPS615 -- Fall Semester 97. by Nancy J. McCracken,Geoffrey C. Fox


1 Interfaces are either public or have the default friendly access (public for the package and private elsewhere)
2 Methods in an interface are always abstract and have the same access as the interface. No other modifiers may be applied
3 Variables in an interface are public, static, and final. They must be initialized.
4 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
5 Interfaces can incorporate one or more other interfaces, using the extends keyword:
  • public interface DoesItAll extends Storable, Paintable {
    • public abstract void doesSomethingElse();
  • }
6 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() {...}
  • }

in Table To:


© 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 Sun Feb 22 1998