TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Proportional Font
Show HTML Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Date: Fri, 17 Apr 1998 13:18:33 -0700
Reply-To: Ben Brosgol <[log in to unmask]>
From: Ben Brosgol <[log in to unmask]>
Content-Transfer-Encoding: 7bit
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Parts/Attachments: text/plain (42 lines)
Martin Carlyle wrote:

<<Near as I can tell, Java has NO multiple inheritance.  Yes, you can
test membership in more than one class hierarchy, but I didn't see a
way to inherit methods from more than one class.  I feel somewhat
silly mentioning this, since my best introduction to Java came from a
tutorial by Ben, so maybe he could enlighten me further if I am
mistaken.>>

I suspect that the C++ and Eiffel religious leaders would claim that Java
does not support multiple inheritance. It's a question of definition of
terms,
and if one regards mi as a good thing then one will want to define it to
include one's own language and exclude the competition :-).

You are right that Java allows a subclass to extend at most one superclass,
and in this sense Java only supports single inheritance.  However, through
the mechanism known as an interface -- which is in effect a stripped-down
class, e.g. with only abstract methods and only final variables
(constants) --
a subclass may extend one superclass and also"implement"  any number
of interfaces.  For example:

   class C1{ int f(){return 1}; }
   interface I1 { int g(); }  // g() is implicitly abstract
   interface I2 { double h(); }  // h is implicitly abstract

   class C2 extends C1 implements I1, I2{
      // implicitly inherit f() from C1
     int g(){ return 0; }
     int h(){ return 0.0; }
   }

C2 may be regarded as "multiply inheriting" from C1, I1, and I2,
but only from C1 does it inherit any method implementations.

Whatever one chooses to call this mechanism, it is quite useful and is
widely exploited in the API.

Ben Brosgol
[log in to unmask]

ATOM RSS1 RSS2