why do we need abstract classes in Java?

user3314801 picture user3314801 · Feb 28, 2014 · Viewed 46.6k times · Source

Why do we need abstract classes in Java? If you're never going to make it into an object, why have it in the first place? How do you use it? Why is it there? I'm wondering the same thing with abstract methods. I find it seems like a similar concept to having a super class with NO subclasses that could ever matter to be made.

Answer

Scary Wombat picture Scary Wombat · Feb 28, 2014

An abstract class can be used as a type of template for other classes. The abstract class will hold common functionality for all classes that extend it.

For example:

Abstract Class Animal 

All animals move and breathe and reproduce so these can be put into the Animal Class.

Now

 Concrete Class Dog, Cat etc.

Have these base functions already provided.