[3284] in java-interest

home help back first fref pref prev next nref lref last post

re:abstract methods

daemon@ATHENA.MIT.EDU (andrew (a.) francis)
Mon Nov 6 11:13:53 1995

Date:  Mon, 6 Nov 1995 07:02:00 -0500 
From: "andrew (a.) francis" <andrewfr@bnr.ca>
To: java-interest@java.sun.com

In message "abstract methods", you write:

> The java spec section 4.10.5 says that abstract methods cannot contain
> a body.  Why is this restriction made?

If the all the methods of abstract classes had method bodies, I don't
understand  why one would want abstract classes in the first place? 
(note: I believe the new  Java language spec needs the keyword "abstract"
to make a method abstract)
 
> There are plenty of situations where it makes sense to have an abstract
> method which also supplies a default body.  In particular, for methods
> where the behavior is to call the superclass' method, then append semantics
> for the subclass.

  Couldn't the same effect be achieved by having a normal base class and
have sub-classes override the methods it is interested in changing, and in
the process, make calls to  the overridden superclass method via the
super variable? Or if you do not want the pseudo-abstract class instantiated,
couldn't you make its constructors protected?

> One may well want these types of functions abstract to force conformance
> to some "well-formed-object" spec which allows objects to work in some
> debug environment, builder environment, etc.

Cheers,
Andrew Francis
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post