Hi, I have a class AAA(abstract), with an abstract method method1(). Class BBB(abstract) extends AAA, but does not contain method1(). Classes CCC1,CCC2(both concrete) extends BBB, and implements method1().
This is shown here
This actually works, but as you can see method1() does not appear in BBB. I guess the point is method1() is being implemented by in a subclass of AAA, its just not a direct subclass, but a sub-subclass.
Is this a bad thing to do, implementing behaviours for methods declared at the top of a hierachy, at the bottom?
Also, I think this only works because BBB is abstract, and if it were not, then it must implement method1().
Consider an exampleMost animals make a sound so it is reasonable to have the makeSound method declared in the Animal class. A mammal doesn't make a specific sound, so there is no need to override the makeSound method in the Mammal class. Dogs and pigs have specific sounds so you implement the makeSound method in those classes.