aspose file tools*
The moose likes Beginning Java and the fly likes Object Class is father of all?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Object Class is father of all??" Watch "Object Class is father of all??" New topic
Author

Object Class is father of all??

Monarch Bhojani
Ranch Hand

Joined: Feb 27, 2005
Posts: 46
hello all
if object class is the base of all classes then the classes we create extending another classes may also extend Object class
Is this not multiple inheritance

Please reply
Regards
Monarch
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
This is not multiple inheritance as you cannot create a class that does NOT extend java.lang.Object.

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

If every Chihuahua extends Dog, and every Dog extends Mammal, would you call this multiple inheritance, since Chihuahuas extend both Dog and Mammal?

It's the same with Object. Every class either DIRECTLY extends Object, unless you declare it to extend something else. But that OTHER class then extends from Object... or from a class that extends Object... or antoher class...

You can trace a direct path up from any class to Object, but each class only had one immediate 'parent' class.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jeff Jetton
Ranch Hand

Joined: Mar 29, 2005
Posts: 71
All good responses. Just to clarify, the fact that classes can inherit from classes that, themselves, inherit from another class is not considered "multiple inheritance". Each class has one, and only one, parent, even though it can have a "grandparent", a "great-grandparent", and so on.

So, what is the definition of multiple inheritance? It's when a class can inherit directly from two or more classes at the same time. In other words, it has multiple "parents". You'd be able to write somthing like this:

class Mule extends Horse, Donkey
{

}

Of course, Java doesn't let you do that. You must use interfaces in order to do something similar (but not exactly) like it. Other languages, most notably C++, do let you acheive true multiple inheritance.

- Jeff
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
You might be implementing multiple inheritance if your hierarchy looks like a directed, acyclic graph (DAG) as opposed to a tree.


James Carman, President<br />Carman Consulting, Inc.
Raj Young
Greenhorn

Joined: Mar 16, 2005
Posts: 9
java supports multiple inheritance with respect to interface but not to implmentation.

So Java's support to multiple inheritance limits with interface, not to implementaion.
 
 
subject: Object Class is father of all??
 
Similar Threads
Super Class
Instance blocks.
Amazed that it compiles?
why Object Class was chosen Parent to all java classes?
Object class