0
Abstract classes?
what is abstract classes?please use simple words to explain
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.
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?
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.