Object Class is father of all??
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
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
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
This is not multiple inheritance as you cannot create a class that does NOT extend java.lang.Object.
Nick
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)
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
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
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
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
posted 20 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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.
| Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |











