Inheritance in Java

Posted by Mandar on Stack Overflow See other posts from Stack Overflow or by Mandar
Published on 2010-05-18T15:33:48Z Indexed on 2010/05/18 15:40 UTC
Read the original article Hit count: 333

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about java

Related posts about inheritance