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

  • The Importance of Doing Laundry
    19

    We could nag, but this is better. It is less work for us to use the words of others to emphasize the importance of doing laundry. Besides, if you saw the way we dressed, you'd laugh your mouse off.

  • EDITOR'S CHOICE
    Data Hiding in Java
    12

    Data Hiding is an aspect of Object Oriented Programming (OOP) that allows developers to protect private data and hide implementation details. In this tutorial we examine basic data hiding techniques in Java.

  • EDITOR'S CHOICE
    Introduction to Windows Notepad
    5

    A useful text editor is an essential component of any personal computer. Every day we need to make notes, compose documents, and record vital pieces of information. We depend on our text editor. Microsoft provided...


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