Anonymous

Why Do We Make A Class Abstract,what Is The Use Of An Abstract Class?

2

2 Answers

Daisy Sarma Profile
Daisy Sarma answered
An abstract class is one that contains a single or multiple abstract methods. It is also called an abstract base class or ABC sometimes. To elaborate, an abstract method, as we all know, is a method that is declared, but has no implementation. Abstract classes may not be instantiated. They also require subclasses, which in turn provide the implementation for the abstract methods. We can understand this better through an example.

Assume that we are creating a model based on the walking styles of all animals. Different animals have different ways of walking, and some also have some unique features they exhibit during walking. However, there are some features that are common to all animals while they walk. So we create a class hierarchy, at the base of which is the base class Animal. The things that animals do uniquely while walking can be categorized as abstract methods. The implementation for these methods would be provided by the different subclasses that exist under animal – e.g., cow, snake, goat, man, etc.

Basically, abstract classes can be said to be superclasses that have in them certain elements that should be implemented by inheritance. An abstract class is used because the abstraction that it helps perform simplifies the process of software development.
Aisha Profile
Aisha answered
An Abstract class is a kind of class that is meaningful only if the language supports the inheritance. It is designed as a parent class and child classes can be derived from it. It is usually used to present abstract concepts or entities. They simplify the software development process for programmers.

Answer Question

Anonymous