0

What is abstract for?

i know what private and public are for but i dont really understand what i would use abstract for? keep it simple please :)

24th Jul 2017, 7:46 PM
D_Stark
D_Stark - avatar
6 Answers
0
If you want a function in a class to be executed, but you don't know how it should be executed, for example if you work in a team.
24th Jul 2017, 8:17 PM
Jonas Schröter
Jonas Schröter - avatar
0
Abstract classes are classes that you can't make objects of. If you try it should throw an error
24th Jul 2017, 9:16 PM
voidneo
0
sounds pointless can yoi give me an example what i would use it for please?
24th Jul 2017, 9:20 PM
D_Stark
D_Stark - avatar
0
I'm not sure since I'm not a java dev, but, imagine you have a superclass Animal, and a subclass cat, you want Animal class to be abstract, there's no animals called Animal, right? So you only can have Cats. Not sure if thats the best example, but is the best I could think of.
24th Jul 2017, 9:29 PM
voidneo
0
thanks noname < wouldent that be classed as a name lol 👍 anyway thanks i think i get it
24th Jul 2017, 9:49 PM
D_Stark
D_Stark - avatar
0
You could just rename the Animal class to Cat, and forget about abstraction, but what if you had to create a class Duck? We put the in common attributes in the animal class and the unique attributes in Cat and Duck classes. This has a name I can't remember.
24th Jul 2017, 9:54 PM
voidneo