Abstraction is the concept of object-oriented programming that “shows” only essential attributes and “hides” unnecessary information. The main purpose of abstraction is hiding the unnecessary details from the users. Abstraction is selecting data from a larger pool to show only relevant details of the object to the user. It helps in reducing programming complexity and efforts. It is one of the most important concepts of OOPs.
Inheritance is a way to reuse code. the class which inherited from, it called the base class(super class), and the class which inherits the code from the base class is called a derived class(sub class). A derived class can use all the functions which are defined in the base class and it can have additional properties or methods.
The ability of creating a new class from an existing class.
Polymorphism gives us a way to use a class exactly like its parent so there is no confusion with mixing types. This being said, each child sub-class keeps its own functions/methods as they are. If we had a superclass called Mammal that has a method called mammalSound(). The sub-classes of Mammals could be Dogs, whales, elephants, and horses. Each of these would have their own iteration of a mammal sound (dog-barks, whale-clicks).
Encapsulation is the concept of associating attributes and methods to an object through a class. When defining a class, we can set certain attributes that any instance of this class will possess. When the makers of Java created Vectors, for instance, they assigned them the attributes capacityIncrement, elementCount, and elementData. When we use a Vector, we can assign it a capacityIncrement and know that, when capacity is reached, the Vector’s capacity will grow by that amount. If we wanted to know the current capacity of our Vector, we could use capacity(), a method that has been encapsulated in the class. Encapsulation represents the idea that these attributes and methods are “inside” of our classes — they are a part of them.