I am curious about how extending the java.lang.Object class works. You can only extend one class and by default every class extends the java.lang.Object class right? What happens when you try to extend another class other than Object. Does it just remove the extends for the Object class and replace it with whatever your extending (roughly)? Thank you for your help!
Yes, that's right. For every class there's a chain of inheritance which starts at the class and recursively goes through the parent classes until it reaches Object.
And yes, when you have an Object reference you can only call methods of the Object class. That's true of every type, in fact; when you have a T reference you can only call methods of the T type.
(I said "type" instead of "class" there because besides classes there are also interfaces, and "type" covers both of those things. I expect you haven't got to interfaces yet so don't worry about that and just pretend I said "class" there.)
Joined: Sep 07, 2011
I have done interfaces so thank you for letting me know it covers them as well. It has been a while since I have done Java and I am refreshing for my Data Structures class that uses Java for the implementations. Thank you for all the great responses!