Article View: borland.public.jbuilder.java.language
Article #15058Re: Multiple inheritance and Java
From: Tom Davies
Date: Thu, 15 Jul 1999 00:00
Date: Thu, 15 Jul 1999 00:00
44 lines
1744 bytes
1744 bytes
Pete Blacker wrote:
>
> Hi
>
> I've done some simple Applet programing in Java, and I've decided to
> start doing some serious work now. I haven't found any comprehensive
> information on OOP in java anywhere. So I still have a very simple
> question unanswered. Does Java support multiple inheritance, if so I
> could use a quick trivial example. I'm not new to OOP but I am new to
> java.
> Thanks for you help, in advance.
>
> Pete Blacker
The first thing to say about multiple inheritance is that its use often
indicates that IS-A and HAS-A has been confused -- that is an aeroplane
doesn't inherit from Fuselage and Wings.
Here's an example of MI of interfaces taken from Arthur J. Riel's book
'Object Oriented Design Heuristics', a useful book.
interface WoodenObject {
public void burn();
public int getDensity();
}
interface Door {
public void open();
public void close();
}
class WoodenDoor implements WoodenObject, Door {
...
}
Of course you might already have an implementation of Door (called
DoorImpl, say)
So you might do:
class WoodenDoor extends Door implements WoodenObject {
...
}
Tom
Technical Details
Message-ID:
<378CF586.9A0CE75F@smartchat.net.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<378BAD59.C08A84FB@comicjunk.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,1b2eda3e22952af9 X-Google-Attributes: gidf74b3,public From: Tom Davies <tom@smartchat.net.au> Subject: Re: Multiple inheritance and Java Date: 1999/07/15 Message-ID: <378CF586.9A0CE75F@smartchat.net.au> X-Deja-AN: 500862667 Content-Transfer-Encoding: 7bit References: <378BAD59.C08A84FB@comicjunk.com> To: Pete Blacker <pete@comicjunk.com> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language