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.
Top comments (8)
hii bro, are you contributing to open source?
i am open to do that.
what is your GitHub
Developer-Amritanshu
Yaar, tera cover koi sense nhi banata. 🤣
dusra mila hi nahi koi acha meme
cool cover image :D
thanks haha :)