A class in Java cannot extend more than one class.
Every class in Java extends java.lang.Object .
From 1 and 2: Any class in Java cannot extend any other class other than java.lang.Object.
What is wrong in this deduction ?
A class in Java cannot extend more than one class.
Every class in Java extends java.lang.Object .
From 1 and 2: Any class in Java cannot extend any other class other than java.lang.Object.
What is wrong in this deduction ?
You can only extend one class at a time. But A can extend B can extend C and so on.
class A extends Object then it cannot extend to any other, but in Java everything is a subclass of Object'sextends Object is completely superfluous.To extend on what Tangens said:
For number 2, it should instead read:
Every class that does not explicitly declare a class it extends extends Object
i.e. if you use the extends keyword, you are now saying that you explicitly extend something other than Object. However, at some point, that extension path will end up back at Object, if you follow the extension hierarchy.
The other part of this is that inheritance is really a chain - you have all of the properties of your parent and their parent and their parent's parent etc. Since the top of this hierarchy is always Object, you must, at one level or another, extend Object.