Hello, recently I went through the inheritance concept.
As we all know, in inheritance, superclass
objects are created/initialized prior to subclass
objects. So if we create an object of subclass
, it will contain all the superclass information.
But I got stuck at one point.
Do the superclass and the subclass methods are present on separate call-stack?
If it is so, is there any specific reason
for same?
If it is not so, why they don't appear on same call-stack?
E.g.
// Superclass
class A {
void play1( ) {
// ....
}
}
// Subclass
class B extends A {
void play2( ) {
//.....
}
}
Then does the above 2 methods i.e play1( )
and play2( )
appear on separate call stack?
Thanks.