This content originally appeared on DEV Community and was authored by Amritanshu Dev Rawat
Data abstraction is the process of hiding certain details and showing only essential information to the user.
An abstract class may or may not have abstract methods but if there is an abstract method then all the child classes have to override it.
You can also do the partial implementation of Abstract Class methods
Abstract class A -> with 30 abstract methods, now you know all the child have to inherit 30 of them but you can also make it work like this:
- class B (child of class A) -> implement 20 methods.
- class C (child of class B or Grandchild of class A) -> implement 10 methods.
- So, it completes the abstract methods.
The abstract class gives features to child classes. So, we restrict object creation because the class is too generic.
Assume we have an Animal class
class Animal { }
when we create an Animal object we can not guess which animal?
Animal animal = new Animal();
cc- does it make any sense?
So, to restrict this, we use abstract keyword.
This content originally appeared on DEV Community and was authored by Amritanshu Dev Rawat
Amritanshu Dev Rawat | Sciencx (2021-06-07T02:52:01+00:00) Abstraction Concept. Retrieved from https://www.scien.cx/2021/06/07/abstraction-concept/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.