AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-inheritance: Who says that java does not support multiple inheritance?

As we know that all classes inherit the Object class by default. Now If we have class A and a sub class of A is Class B. Then class B inherits two classes Class A and Object. That is multiple inheritance. Please explain the proper reason.

corejava x 353
inheritance x 7
Posted On : 2014-05-09 17:21:03.0
profile Rishi Kumar - anyforum.in Rishi Kumar
523188245674
up-rate
4
down-rate

Answers


First i think you should focus on the actual meaning of multiple inheritance - Multiple inheritance is about multiple-direct-inheritance. That is a class can have two immediate parents. In java no class is allowed to have two immediate parent classes.
A class that extends that other class, but it extends Object, too, so you are still in one line of inheritance, not multiple inheritance. A single class can?t have two immediate parent classes it can have grandparent class though. Let us make it better understandable by following example:

Note:
-----------
If A extends B and B extends C, is not the same thing as A extends both B and C. In java a class that has no parent class by default its parent would be Object class. Consider following example:

class Animal {
}

class Cat extends Animal {
}

class Tiger extends Cat {
}

In the above example Tiger inherits from Cat which inherits from Animal which (by default) inherits from Object. In above case Object class is the parent of Animal and grandparent of Cat class. So in this way we says that Object class is the parent of all classes.

Posted On : 2014-05-09 18:02:36
Satisfied : 2 Yes  1 No
profile Garima Gupta - anyforum.in Garima Gupta
596129554551
Reply This Thread
up-rate
4
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in