Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

multiple inheritance  RSS feed

 
catherine matthews
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does java provide ways to do multiple inheritance? How class B inherit both class A and class B.
 
Sanjaya Sugiarto
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only extend one class.
You can implements one or more interfaces though.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by catherine matthews:
Does java provide ways to do multiple inheritance? How class B inherit both class A and class B.


About multiple inheritance Sanjaya gave you solution. And about

How class B inherit both class A and class B


No A class cann't extend more then 1 class at a time.

But you misspelt somewhere.

Are you menat this
A class is implicitly inherit ownself


Come up with clear confusion
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, one interesting consideration is that inner classes can inherit independently from their enclosing class. So considering the special "link" an inner class has to its enclosing class, this might be considered a form of multiple inheritance...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!