We know that Object class is super class of every class & a class extends only one class. so how is it possible to a class to extend other than Object class?

Because java supports multilevel inheritance.

Questions by tulasi   answers by tulasi

Showing Answers 1 - 2 of 2 Answers

case 1

suppose you have a class Test, which doesn't extend any other class. So by default, Object becomes it's super class.

                                   Object->Test

case 2

If your Test class wants to extend some other class, for example Hashtable, your class will become a sub class of Object through Hashtable because Hashtable is a subclass of Object. Any class you are trying to extend will be a subclass of Object directly or due to hierarchy. 

                                    Object->Map->Hashtable->Test

Object is the superclass of Test even when you have Test extend HahTable

So according to case 1 Test is a subclass of Object directly.

According to case 2 Test is a subclass of Object due to the hierarchy.

so no matter you extend a class or not, your class will always be a subclass of Object.

mandyjoshi

  • Nov 11th, 2005
 

The half answer is explain by Krishna Prasad and Other half lies in answer of question why java does not support multiple inheritance. And how it has solved that problem using interfaces. 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions