DEV Community

Cover image for Abstraction Concept
Amritanshu Dev Rawat
Amritanshu Dev Rawat

Posted on

Abstraction Concept

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();

image

cc- does it make any sense?

So, to restrict this, we use abstract keyword.

Top comments (8)

Collapse
 
keshavcodex profile image
Keshav Kumar

hii bro, are you contributing to open source?

Collapse
 
amritanshu profile image
Amritanshu Dev Rawat

i am open to do that.

Collapse
 
keshavcodex profile image
Keshav Kumar

what is your GitHub

Thread Thread
 
amritanshu profile image
Amritanshu Dev Rawat

Developer-Amritanshu

Collapse
 
line profile image
Chaitanya Prabuddha

Yaar, tera cover koi sense nhi banata. 🤣

Collapse
 
amritanshu profile image
Amritanshu Dev Rawat • Edited

dusra mila hi nahi koi acha meme

Collapse
 
jarjanazy profile image
Abdulcelil Cercenazi

cool cover image :D

Collapse
 
amritanshu profile image
Amritanshu Dev Rawat

thanks haha :)