[D] DejaVU Online: Principles of Object-Oriented Software Development (©)
[D] - [up] [top] - [I] [II] [III] [IV] - [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] - [A] [R]

Instructors' Guide


Introduction Terminology Expressions Control Objects Inheritance Technology Summary

Objects

An object is an instance of a class. In Java, a program is executed by calling the static main method a class. Look for example at the HelloWorld class in slide Java-objects-1.

Hello World -- Java (1)

  public class HelloWorld {
  public static void main(String[] args) {
         System.out.println("Hello World");
         }
  };
  

slide: Java -- objects (1)

The HelloWorld example is taken from a collection of hello world programs located at http://www.latech.edu/~acm/HelloWorld.shtml . See hello for a sample of this collection.

To illustrate the use of interface definitions, slide Java-objects-2 presents a slightly modified version. The actual HelloWorld class announces that it implements the World interface.


Hello World - interface

  public interface World {
  public void hello();
  };
  

Hello World - class

  public class HelloWorld implements World {
  public void hello() {
         System.out.println("Hello World");
         }
  };
  

slide: Java -- objects (2)

Both classes make use of the standard out stream defined in the class System to emit their message to the world.
[D] - [up] [top] - [I] [II] [III] [IV] - [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] - [A] [R]
Hush Online Technology
hush@cs.vu.nl
12/29/99