Article View: borland.public.jbuilder.java.language
Article #15048Re: Multiple inheritance and Java
From: Matt Welsh
Date: Tue, 13 Jul 1999 00:00
Date: Tue, 13 Jul 1999 00:00
58 lines
2202 bytes
2202 bytes
Hi Pete...
In the sense that you cannot inherit from more than one base class
Java does not support MI, *however* it does support the implementation
of interfaces which provides the assets of MI without the headaches.
A simple way to think of it is that the benefits are achieved thru
casting objects to interface type or testing against it.
For example if you have a class A that extends B and implements X
it can be treated in comparisons as B or X like this:
if (A instanceof X) would return true.
if (A instanceof B) would also return true.
Further you can have a method, myMethod, that "returned" an interface
type, like this:
public X myMethod() {
return new A();
}
You can the test against, say, type B or type X:
if (myMethod() instanceof B) would return true.
if (myMethod() instanceof X) would also return true.
Keep in mind that this is intended to be a simplified overview of the
idea of how to use interfaces, and not a formalized description of how
it should be done.
-Matt
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
--
/**
* Matt Welsh
* Borland
* R&D Engineer, JBuilder
*
* @param email mwelsh@Borland.com
* @param WWW http://www.borland.com
* @deprecated http://www.inprise.com
*/
Technical Details
Message-ID:
<378BBBD9.40E9E4B9@inprise.com>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: Matt Welsh <mwelsh@inprise.com> Subject: Re: Multiple inheritance and Java Date: 1999/07/13 Message-ID: <378BBBD9.40E9E4B9@inprise.com> X-Deja-AN: 500695657 Content-Transfer-Encoding: 7bit References: <378BAD59.C08A84FB@comicjunk.com> Organization: Inprise Corporation Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language