OOPs Concepts in Java:

Spread the love

You can remember it by saying “A PIE”

A stands for Abstraction

P stands for Polymorphism

I stands for Inheritance

E stands for Encapsulation.

Let’s see what they mean:

  1. Inheritance: Inheritance is a process where one class acquires the properties and methods of another. Eg:, Class A extends B
  2. Encapsulation: Encapsulation in Java is a mechanism of wrapping up the data and code together as a single unit. In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class. Eg.; private variable.
  3. Abstraction: Abstraction is the technique of hiding the implementation details from the user and only providing the functionality to the users. In java it is achieved through Interfaces and Abstract classes.
  4. Polymorphism: Polymorphism is the ability of a variable, function or object to take multiple forms or you can sau exist in multiple forms. There are two types of polymorphism in Java: compile-time polymorphism and runtime polymorphism. We can perform polymorphism in java by method overloading and method overriding.