0
What is the purpose of abstract class. Explanation needed with real world example. The scenario where it is used.
I could understand the concept I need the example where we are using it(in programming) thread concept is used railway reservation system, ticket booking system. I need a similar example
3 Respuestas
+ 2
This is really more to do with how you code from a design perspective. By definition, an abstract class is.. abstract, it can't be instantiated.
You could have an abstract Mammal class. This can have basic elements of mammal attributes and behavior, but what sound might it make? We don't know, so the makeSound() method would be abstract (necessarily making the class abstract). Now Dog, Cat, Elephant classes can extend Mammal to override and implement the abstract methods.
So really, it's a design thing where you want a set of classes to conform to some kind of pattern - maybe it's a set of business processes that initialize or modify the data in a particular way (so initialize or execute are the abstract methods) or a set of application pages with a common layout etc.
+ 1
To drive a car you don't need to know how engine works, this is an example of abstraction i.e you hide the inner working and shows user only the essential stuff. in our example, accelerator, brake,etc are the essential stuff and we are not concerned with what happens inside engine when we press the accelerator
0
I could understand the concept I need the example where we are using it(in programming, thread concept is used railway reservation system, ticket booking system. I need a similar example)