Basic HTML version of Foils prepared Sept 6 1998

Foil 34 Java Language -- Interfaces - Overview

From Java Tutorial 98-2: Java Language and Object Oriented Techniques CPS606 Fall Semester 1999 -- Sept 7 1999. by Geoffrey C. Fox, Nancy McCracken


1 An interface specifies a collection of methods (behaviors) without implementing their bodies (akin to giving the API).
  • public interface Storable {
    • public abstract void store(Stream s);
    • public abstract void retrieve(Stream s);
    • }
2 Any other class which implements the interface is guaranteeing that it will have the set of behaviors, and will give concrete bodies to the methods of the interface.
3 Interfaces solve some of the same problems as multiple inheritance, without as much overhead at runtime.
  • There is a small performance penalty because interfaces involve dynamic method binding.
4 Interfaces can be implemented by classes on unrelated inheritance trees, making it unnecessary to add methods to common superclass.

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 Mon Sep 6 1999