OOP Interfaces Demo in Java - Part 2

OOP Interfaces Demo in Java - Part 2

Introduction

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();
}

More by this Author


Comments

No comments yet.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working