Question about extending classes

Discussion in 'Plugin Development' started by skeletonofchaos, Aug 25, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    skeletonofchaos

    Sorry quick question:
    (Pseudocode)
    class a(){
    method(){
    //do something
    }
    }
    class b() extends a{
    method(){
    //do something else
    }
    }
    public a getA(){
    return new b();
    }
    now if I do the following:
    getA().method will it do a's method or b's method?

    Never mind just wrote some test code it executes b's method.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 19, 2016
  2. It doesnt matter what generalized type you return/specify. The instance you created is still of the b class.
     
Thread Status:
Not open for further replies.

Share This Page