0

Abstract classes?

what is abstract classes?please use simple words to explain

25th Oct 2017, 4:05 AM
oyl
3 Answers
+ 1
A class that cannot or should not form objects. Math in the standard library is abstract. You cannot make a new Math. Also a class must be abstract, when you do not implement all methods.
25th Oct 2017, 4:38 AM
1of3
1of3 - avatar
0
@1of3 so it cannot and should not form object and can contain methods that do not need to be implemented.then whats the use of putting it there?
25th Oct 2017, 6:47 AM
oyl
0
Two different reasons: 1 In Java all code must be in a class. Other languages do that differently. But this is Java, so you have things like Math that only contain some functions. 2 Classes that should not. Say you have classes for mammals. Dog, Badger, Gorilla. They all extend the class Mammal. But there should never be just a Mammal. It should always be some specific kind of Mammal. So make Mammal abstract.
26th Oct 2017, 5:22 AM
1of3
1of3 - avatar