aspose file tools*
The moose likes Beginning Java and the fly likes Mutliple inheritance in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Mutliple inheritance in Java" Watch "Mutliple inheritance in Java" New topic
Author

Mutliple inheritance in Java

narain ashwin
Ranch Hand

Joined: Dec 27, 2007
Posts: 48
I am suspecting my understanding that JAVA doesn't support multiple inheritance

Consider this class

We can say that this class extends the Object class.But if I modify the above class to implement threading

seems like MyClass extending both Object class (implicitly) and Thread class (explicitly).Doesn't that means multiple-inheritance?


I drink two cappuccinos a day.Is that of any help to solve java problems??
JBoss 6 - Admin console Username/pwd: admin/admin
Roland Maurer
Greenhorn

Joined: Nov 23, 2008
Posts: 17
one java class can not be extended from more than one superclass.

class A extends B,C is not working !!

but you can do eg:

class A implements B,C,...

seems like MyClass extending both Object class (implicitly) and Thread class (explicitly).Doesn't that means multiple-inheritance?


your class extends Thread and Thread extends Object or something else ..


http://en.wikipedia.org/wiki/Multiple_inheritance


Originally posted by narain ashwin:
I am suspecting my understanding that JAVA doesn't support multiple inheritance

Consider this class

We can say that this class extends the Object class.But if I modify the above class to implement threading

seems like MyClass extending both Object class (implicitly) and Thread class (explicitly).Doesn't that means multiple-inheritance?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11499
    
  16

a class cannot DIRECTLY extend more than one class. it can only have one parent. However, it can have a grand-parent, a great-grand-parent, etc.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mutliple inheritance in Java