I have a question on Inheritance in Java programming language. It is said that every class automatically extends the class Object. If it is so then how are we able to extend other classes?
Like:
class MyClass extends Test1 ---
but if it is extending Object class then it would be like this
class MyClass extends Object,Test1
--
--
which is not allowed in java.
Please comment on it.
Hai raa.. I have got an explanation if you feel its wrong please correct me :
ReplyDeleteStraight forward answer to that question would be java doesnt support multiple inheritance but java supports multilevel inheritance
In the case you mentioned above, MyClass explicitly extends Test1 which implicitly extends Object class thus super class of Myclass is Test1 and super class of Test1 is Myclass
sorry guys in the above comment last line it is super class of Test1 is Object class
ReplyDelete