So I just had this question on an exam "Is it useful to have an abstract class without Abstract methods?". I would really like to know if I had it right because my answer was no.
Asked
Active
Viewed 57 times
0
-
It's a fair question, but there's no one good answer. For your exam, the right answer was probably whatever you [should have] learned in class. Possibly either "yes" or "no" was right, provided you gave a good justification for it. – John Bollinger Jan 28 '15 at 15:08
-
It should be No, It is similar to marker interface like serializable, Clonnable ,etc which will be useful to identify the type of the instance which was created. Instead of having marker Abstract class use Interface – Vinayak Dornala Jan 28 '15 at 15:08
-
@Vinayak, an abstract class that defined no methods at all would be a sort of weak sibling to a marker interface, but what about an abstract _base_ class (i.e., a class that defines fields and methods that operate on those fields) but none of the methods is formally declared `abstract`? Follow the "this question already has an answer" link to see examples. – Solomon Slow Jan 28 '15 at 15:23