kri shan wrote:How to call abstract child class method in Parent abstract class ?
1. Given just this code, you won't be able to make
any calls to anything. Both classes are declared as abstract so while there is a potential to make polymorphic calls later on in a concrete class, the code you just show will not do anything because you can't instantiate abstract classes.
2. Be careful what you wish for. A superclass should not have any logic in it that demonstrate any knowledge of a specific subclass. To do so would violate object-orientation rules and it results in very brittle code. If you were designing that call to be polymorphic, then that's fine. It's like saying "I want to have a method,
blah(), that should behave in a certain general way but I will leave it to whatever subclass that extends me to decide what the specifics are." If, on the other hand, you design that method call you're making from the superclass to the subclass method as something like, "I know my subclass ClassB is going to inherit and implement my
blah() method, let call
that one instead" then this is what I like to call "Superclass having inappropriate knowledge of its subclass" -- if you like to use the names Parent/Child instead, you can think of it as "Parent class having incestuous relations with its Child class." Yes, it's that gross of a design.