Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
A simple way to think why you would need a abstract class is to ask your self can I create an object of this in real life. there are many things which you cant to name a few would be a Machine,Animal,Mammal,Fruit,Vegetable ect ect... so even though you dont know what a Animal looks like you can still get a idea of what a animal might do So these should be abstract classes which will have the basics of what your object/classes will extend from. For example Abstract class Animal{ //variables would be they all have names they all have a colour //methods/overridden methods would be. they all can sleep() they all can wake() they all can eat() they all make sounds() } And then you extend your diffrent types of Animals from the abstract class these will be the real life objects like cat, dog ect.. Hope that helps.
26th Sep 2019, 5:25 PM
D_Stark
D_Stark - avatar