[3374] in java-interest
Re: JAVA: What are ABSTRACT CLASSES etc.?
daemon@ATHENA.MIT.EDU (Michael Lorton)
Thu Nov 9 19:09:36 1995
Date: Thu, 9 Nov 1995 11:47:39 -0800
From: Michael Lorton <mlorton@eshop.com>
To: michael@w3media.com
Cc: java-interest@java.sun.com
In-Reply-To: <199511090130.RAA09367@vv.val.net> (michael@w3media.com)
> 1) What the hell are "abstract classes"?
A class which cannot be instantiated because some of its methods are
not implemented. Consider a Shape class, with some data members like
parent and context, and a draw() method. Clearly the draw() method
cannot be implemented for a Shape -- it must be implemented for some
derived class like Square or Circle.
> 2) Which brings me to "interfaces" which don't make sense to me either.
An interface defines a category of classes which all have particular
methods. For example, several otherwise unrelated classes might offer
compare(), which returns -1, 0, or 1; these could all be implementing
the Comparable interface. A sorting routine could implemented to sort
any collection of Comparables.
> 4)And finally - yes 'threading'.
> 1.Subclass the Thread class defined in the java.lang package and
> override the run() method.
> 2.Provide a class that implements the Runnable interface, also defined
> in the java.lang package. Now, when you instantiate a thread (either
> directly from the Thread class, or from a subclass of Thread), give
> the new thread a handle to an instance of your Runnable class. This
> Runnable object provides the run() method to the thread.
>
> I don't understand the second method.
The default thing to do in the run() method of a Thread is to invoke
the run() method of the Runnable it holds.
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com