ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software

OOP Interfaces Demo in Java - Part 2

Updated on July 13, 2009

OOP Interfaces Demo in Java - Part 2


This is Part 2 of a 5 part series on programming Interfaces in Java. Links to the other tutorials are provided at the beginning and end.

The concept of an Interface in Java is designed to replace the functionality of multiple inheritance. C++, another object oriented programming language, supports multiple inheritance, Java does not. While Interfaces are very common in Java programming, some programmers avoid them. This example of OOP Interfaces Demo in Java provides an introduction to creating, implementing, and applying interfaces in the Java programming language. We illustrate OOP concepts with functional java source code and accompanying documentation.

package InterfaceDemo;
 * @author nicomp
 * We will create two classes that are not directly related but still share some
 *  process (or method) names at a conceptual level.
 * For example: we 'build' a NetBeans project and we also 'build' a car.
 * This interface will require the classes that implement it to
 * each provide an implementation of a 'build' method.
 * The design process is supported here because we don't need complete domain knowledge.
 * We can write the method interfaces and have them filled in later by someone
 *  who knows what they are talking about. 
public interface InterfaceDemo {
//  This looks suspiciously like a C++ prototype.
//  The method has no body, just a method signature. There's no executable code.
    public boolean Build();


    0 of 8192 characters used
    Post Comment

    No comments yet.