No Kaustubh No Fun, Know Kaustubh Know Fun..
Subhash Kumar
Attitude is everything
Kaustubh G Sharma wrote:As in java we can't extends multipul classed to save from multipul inheritance ... As from my knowledge Object class is the super class for every class in java and it extends in implicitly then don't you think that it breaks the contract for multipul inheritance when we extend other class ???...
please clear my doubt...
Kaustubh
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:For a real world example, A son can have only one Father, but a Father can have multiple Sons!
Regards,
Avishkar Nikale
BEE MBA PMP SCJP-6
Jesper Young wrote:
Abimaran Kugathasan wrote:For a real world example, A son can have only one Father, but a Father can have multiple Sons!
Interesting comparison, but you should be aware that the meaning of the word "inheritance" in object oriented programming is very different from the biological meaning of the word. Pretending that they are analogous is often very confusing.
In object oriented programming, when class B is a subclass of class A, it means that B is an A (the Liskov substitution principle). To be more precise, it means that B is a specialized kind of A.
For example, you could have a class Animal with a subclass Mammal. That fits with the object oriented meaning of inheritance: a Mammal is a certain kind of Animal. Some people name classes "Parent" and "Child" (or "Father" and "Son") - that's wrong and confuses the biological meaning of "inheritance" with the object oriented meaning, because a Child is not a special kind of Parent.
Your analogy doesn't really hold for multiple inheritance, because there are programming languages (C++, for example) which do allow multiple inheritance - does that mean that in C++ a Son can have multiple Fathers?
Kaustubh G Sharma: Multiple inheritance means that a class has multiple superclasses at the same level - not that it has multiple superclasses at different levels of the class hierarchy. Java doesn't have multiple inheritance, because you almost never need it in practice and because it causes difficult problems such as the diamond problem. (In C++ this was solved by adding an extra feature to the language: virtual inheritance, making the language more complex than it already was...).
So at any point of time in your class hierarchy you will always have Object at the top level.
No Kaustubh No Fun, Know Kaustubh Know Fun..
No Kaustubh No Fun, Know Kaustubh Know Fun..
You get good luck from rubbing the belly of a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|