Java OOPs Concepts

The main OOPs Concepts in Java are as follows:

1. Abstraction:

Abstraction is a way of hiding complexity. Let us take the example of a car. We know that if the accelerator is pressed, the speed will increase but don’t know the internal process of how speed will be increased.

2. Encapsulation:

Encapsulation is a mechanism of wrapping code and data into a single unit. Let us take an example of HR in a company. If you have any query then you will communicate through HR not directly with the departments. HR acts as a public interface here.

3. Polymorphism:

Polymorphism means more than one form. In Java polymorphism is a mechanism in which something behaves differently based on its call. Water can be of any form solid, liquid, or gas.

4. Inheritance:

Inheritance is the way of code re-usability. Consider an example of parent and child. A child inherits the properties of its parent.