Week 7 - Objects, Interfaces, Packages

Recommended Reading:

Make sure you read Objects and Classes in Java from the tutorial to see how OO is done in Java.

Java OO Fundamentals

Objects

When we refer to "objects" in Java, we are talking about "classes"--Just like in C++.

OO concepts and how they are done in Java:

Interfaces

Interfaces are how Java addresses the issue of multiple-inheritance. This is because there is no multiple-inheritance in Java in the traditional sense.

Things to remember about interfaces:

Packages

Packages are Java's approach to creating re-usable modules. A package is included in a program via the import keyword. This is analagous to the #include directive in C. One package that is always included by default is java.lang.

To write packages of your own, simply type the keyword package at the top of a file containing a number of classes that you wish to re-use. A package can span multiple files. Each file that is part of a package will need the line package package-name near the top of the file.

If you want to look at the Java source code for the packages that come with the JDK, they are found in the directory /usr/local/java/src.

Some Practical Java Objects

Applets

Some useful methods in Applets:

Look at the section in the tutorial about Writing Applets for more info. Plan on some of the stuff in here being on a test.

Threads

If we can get around to talking about these, that would be cool.

Otherwise, look here for info on using threads.

Other Miscellany

Look at the Essential Java Classes page on the tutorial.

Check out the following package specifications for some useful, general-purpose objects:


Changelog


2/25/99 - Initial revision, in the afternoon, changes made at night.
3/01/99 - Added 'Essential Java Classes' link and 'Recommended Reading'.