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 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.