so what do they really mean by superclass constructor is invoked?Does that not mean superclass object is created?An object at depth three in inheritance tree will need three objects created and at depth six will need six objects created?
Hmm, that's the second time today I've read here that someone thought each class along the chain of inheritence was a separate object. I wonder if it's being taught that way.
As Mike said, each instance of any class is a single object. When you instantiate class B that extends class A that extends Object, one single chunk of memory is allocated for the single instance of B. That memory will hold the instance fields for Object, A, and B plus the standard instance overhead (at least the instance's Class).
When each constructor is called in the chain, they only initialize the fields of the memory block -- the memory has already been allocated.
Mike, I meant that if class B above defines no fields, then its memory block will be the same size as an instance of class B. I could easily be mistaken on that, though, but I can't think of what it would need to add.
Screaming fools! It's nothing more than a tiny ad: