•How are constructors invoked in case of inheritance?
•For example if there three classes A,B and C. B derives A and C derives B.
•If we create an object for the subclass C, the constructor that is to be invoked first is the default constructor of A and then the default constructor of B and finally the default constructor of C will be invoked.
•So, the order of invocation is from super class to sub classes.
•For example if there three classes A,B and C. B derives A and C derives B.
•If we create an object for the subclass C, the constructor that is to be invoked first is the default constructor of A and then the default constructor of B and finally the default constructor of C will be invoked.
•So, the order of invocation is from super class to sub classes.
No comments:
Post a Comment